Help With First Script File
crowdata
Global Mapper UserTrusted User
I'm using a registered version of GM 15.0
I've created (my first) basic gms script file for importing ASCII point data only as follows:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
IMPORT_ASCII FILENAME="C:\Temp\gmimport.txt" TYPE=POINT_ONLY COORD_DELIM=COMMA COORD_ORDER=Y_FIRST INC_COORD_LINE_ATTRS=YES
I'm running it from a bat file, it seems to run because I get the GM "Unknown Projection" window screen. I click OK
and the window closes and that's it. I don't see the imported data anywhere in GM.
If I run the script from within GM I see the data plotted correctly in a new layer with the file import name.
My questions are:
1. Where does the data go when I import it from a batch file? The import seems to work but I can't see it anywhere in GM
2. How do I direct the import to a specific gmw file
3. Where do I set the import projection.
Randy Crowley
I've created (my first) basic gms script file for importing ASCII point data only as follows:
GLOBAL_MAPPER_SCRIPT VERSION=1.00
IMPORT_ASCII FILENAME="C:\Temp\gmimport.txt" TYPE=POINT_ONLY COORD_DELIM=COMMA COORD_ORDER=Y_FIRST INC_COORD_LINE_ATTRS=YES
I'm running it from a bat file, it seems to run because I get the GM "Unknown Projection" window screen. I click OK
and the window closes and that's it. I don't see the imported data anywhere in GM.
If I run the script from within GM I see the data plotted correctly in a new layer with the file import name.
My questions are:
1. Where does the data go when I import it from a batch file? The import seems to work but I can't see it anywhere in GM
2. How do I direct the import to a specific gmw file
3. Where do I set the import projection.
Randy Crowley
Comments
-
Randy,
If you run using the File->Run Script menu command there is a checkbox to control whether the script runs in the context of the main map view or not. If unchecked the script runs in its own sandbox so any data loaded by the script will be unloaded at the end.
If you are running from a batch file and you name the script as .gmw rather than .gms it will load in the main map view if passed on the command line. If passed as a .gms file the script runs and then the application immediately exits. This is for batch processing with no interface.
You can pass the projection using the PROJ parameter for the IMPORT_ASCII command. This allows projection specifications in a number of ways, including EPSG code, PRJ filename, or a previous DEFINE_PROJ definition. See Global Mapper Scripting Reference for details.
You can also load a file in the main user interface and save a workspace file then look at it in a text editor to see how to set some options. A .gmw file is a script.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Thanks Mike
I renamed the script from gms file to gmw and the file imports and displays correctly.
Now I have a one layer gmw with all my points and all my "work" is in my main gmw file. So, I need to put the two gmw files together. I do not want to alter my "main" gmw file.
Can I do this in my script by chaining to my "Main" gmw file and have everything come together?
Randy -
Randy,
Yes you can use the EMBED_SCRIPT command to pull in another script/workspace from another.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Thanks Mike
This part now works well. I can import my point file into a new layer then with the embed_script I can bring the other layers in from my other working file. Beautifull!
What I need to do now is to export back to csv any of the imported points that fall within a polygon on a different layer. That layer has only one polygon and there are no other points, lines etc. of any kind in the polygon layer.
The polygon layer is named "District1". How can I script to export all the imported point data and all its attributes that fall within "District 1" to a csv file?
Randy -
Randy,
You can use EXPORT_VECTOR to export to a CSV and use the POLYGON_CROP_FILE parameter to specify the name of the file with the crop polygon. Then you should just get the points that are in that polygon.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Mike
The polygon is embedded, it's not a file that I can reference. Can I reference the layer name?
Randy -
Randy,
Currently the crop polygon either has to be an existing named one defined in the script itself or something from a file. But you could export the polygon to a file, then use that to crop, then delete the file with the RUN_COMMAND script command.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Hi Mike
I can do that. To what format would you suggest I save the embedded polygons?
Randy -
Randy,
Any format with a projection would be best, I would suggest maybe KML so you only have one file to delete after doing the export.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation
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