Script to JPG file export
mek
Global Mapper User
Hello, I am new here and my English is bad, excuse me.
I am making script to open a map, change then projection and export to a JPG file, changing de pixel spacing.
My question is the following one. How I can change from script the “pixel spacing”?
Thanks.
example:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
DEFINE_PROJ PROJ_NAME="PROJ_UTM"
Projection UTM
Datum EUROPEAN_1950_(SPAIN_AND_PORTUGAL)
Zunits NO
Units METERS
Zone 30
Xshift 0.000000
Yshift 0.000000
Parameters
END_DEFINE_PROJ
IMPORT FILENAME="D:\MAPS\o_90_13_10M.jpg" \
TYPE=AUTO PROJ_NAME="PROJ_UTM"
DEFINE_PROJ PROJ_NAME="PROJ_GEO"
Projection GEOGRAPHIC
Datum WGS84
Zunits NO
Units DD
Xshift 0.000000
Yshift 0.000000
Parameters
END_DEFINE_PROJ
LOAD_PROJECTION PROJ_NAME="PROJ_GEO"
EXPORT_RASTER FILENAME="D:\MAPS\o_90_13_10M_1mpix.jpg" \
TYPE=JPEG FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES
I am making script to open a map, change then projection and export to a JPG file, changing de pixel spacing.
My question is the following one. How I can change from script the “pixel spacing”?
Thanks.
example:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
UNLOAD_ALL
DEFINE_PROJ PROJ_NAME="PROJ_UTM"
Projection UTM
Datum EUROPEAN_1950_(SPAIN_AND_PORTUGAL)
Zunits NO
Units METERS
Zone 30
Xshift 0.000000
Yshift 0.000000
Parameters
END_DEFINE_PROJ
IMPORT FILENAME="D:\MAPS\o_90_13_10M.jpg" \
TYPE=AUTO PROJ_NAME="PROJ_UTM"
DEFINE_PROJ PROJ_NAME="PROJ_GEO"
Projection GEOGRAPHIC
Datum WGS84
Zunits NO
Units DD
Xshift 0.000000
Yshift 0.000000
Parameters
END_DEFINE_PROJ
LOAD_PROJECTION PROJ_NAME="PROJ_GEO"
EXPORT_RASTER FILENAME="D:\MAPS\o_90_13_10M_1mpix.jpg" \
TYPE=JPEG FORCE_SQUARE_PIXELS=YES GEN_WORLD_FILE=YES GEN_PRJ_FILE=YES
Comments
-
Just add a SPATIAL_RES parameter to your EXPORT_RASTER script command specifying the desired sample spacing for the export. Here is the documentation for that parameter:
SPATIAL_RES - specifies spatial resolution. Defaults to the minimum spatial resolution of all loaded data if not specified. Should be formatted as x_resolution,y_resolution. The units are the units of the current global projection. For example, if UTM was the current global projection and you wanted to export at 30 meter spacing, the parameter/value pair would look like SPATIAL_RES=30.0,30.0.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
Thank you, Mike.
The problem is that mi projection must be in Geographic, the units in Arc Degrees and i need put de "pixel spacing" in Meters. -
You have to specify the pixel spacing in your export projection as you can't resample data in units other than what you are exporting in. What you can do is start the export in the GUI to get an approximate degrees value for a 1m x 1m export using the 'Calculate Spacing in Other Units' button, then use those in your script. Note that there is not a simple conversion factor from meters to degrees as one is a linear unit and the other an angular unit. The conversion will vary from place to place on the earth.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Support
support@globalmapper.com -
For what it's worth....this is one that's stumped me on a number of occasions also. Would be nice if GM could automatically convert.
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 628 GM Script Language
- 53 User Scripts
- 113 GPS Features
- 414 Projection Questions
- 819 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 177 Announcement and News
- 908 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 562 Other Discussion
- 129 GIS Data Sources
- 27 Global Mapper Showcase
- 233 How I use Global Mapper
- 107 Global Mapper Forum Website