- globalmapper.SaveProjectionToFile(string aFilename, GM_Projection_t aProj, uint32 aReserved=0) GM_Error_t32
-
Saves a GM_Projection_t structure to a projection (PRJ) file.
- Parameters:
-
aFilename (str) – filename of projection file to save to
aProj (GM_Projection_t) – projection to save
aReserved (uint32) – Reserved for future use; defaults to 0
- Returns:
-
Error Code
- Return type:
-
GM_Error_t32
Example
The following is an example of SaveProjectionToFile.
import os
import globalmapper as gm
export_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "../../misc/save_proj_file_output/")
os.makedirs(export_dir, exist_ok=True)
### START SAMPLE
err_SaveProjectionToFile = gm.SaveProjectionToFile(
export_dir + "saved_proj.prj", gm.GM_Projection_t(), 0
)
### END SAMPLE
assert (
gm.GM_Error_None == err_SaveProjectionToFile
), f"SaveProjectionToFile: Expected {gm.GM_Error_None}, got {err_SaveProjectionToFile}"
assert os.path.isdir(export_dir), f"Error creating the export directory: {export_dir}"
# Expected path for file export
exported_filepath = os.path.join(export_dir, "saved_proj.prj")
# Assert that the final expected output file exists and is not empty
assert os.path.exists(
exported_filepath
), f"Expected output file does not exist: {exported_filepath}"
assert (
os.path.getsize(exported_filepath) > 0
), f"Exported file is empty: {exported_filepath}"
For more context refer to the tutorial page on setting projections.