Multiple export hiSHP to KML without losing attributes
sonchika
Global Mapper User
Hi!
Is it somehow possible to use command Batch Convert/Reproject to export multiple SHP to KML - one by one and without losing colors defined in area stiles?
I have many shapefiles to export to KML, but it is time-consuming to export one by one via Export vector format command. This one works great and exports colors too, but I would like to fasten my work.
Thank you for your answer.
Is it somehow possible to use command Batch Convert/Reproject to export multiple SHP to KML - one by one and without losing colors defined in area stiles?
I have many shapefiles to export to KML, but it is time-consuming to export one by one via Export vector format command. This one works great and exports colors too, but I would like to fasten my work.
Thank you for your answer.
Comments
-
To export already loaded layers one at a time with the settings (including styles) already set up for them I would suggest using a script. You can use the LAYER_LOOP_START...LAYER_LOOP_END command to loop over the loaded files and export them out to KML using EXPORT_VECTOR. See Global Mapper Scripting Reference for details along with an example that does almost the same thing, just with different file formats.
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
I've seen your tutorial on Youtube, as I'm a complete newbie to scripting.
And the result is:
GLOBAL_MAPPER_SCRIPT VERSION="1.00"
DIR_LOOP_START DIRECTORY="C:\GIS\Projekti\Divaca_Ber_10ocen_met9\Testno\script" FILENAME_MASKS="*.shp"
IMPORT FILENAME="%FNAME_W_DIR%"
EXPORT_VECTOR FILENAME="C:\GIS\Projekti\Divaca_Ber_10ocen_met9\Testno\script\%FNAME_WO_EXT%.KML" TYPE=KML
UNLOAD_ALL
DIR_LOOP_END
BUT: what do I have to write, if I want to export area styles too?
Area styles are assigned to attributes. For each shapefile I have 10 different colours assigned. Is it possible to define area stye that consist of 10 different colors, whick apply to 10 grades I have in attribute table? -
OR: Is it possible to define area styles as I define them in Overlay Control Center - area styles - Apply styling based on attribute. There I use command Load from file to assign colors. Now, that colors I would like to export to KML.
-
The DIR_LOOP_START...DIR_LOOP_END will load the files new from disk. I think you want to use the ones you already have loaded with the styles you have set there, so you need to use LAYER_LOOP_START...LAYER_LOOP_END which loops over already loaded layers. Try something like the following:
GLOBAL_MAPPER_SCRIPT VERSION="1.00"
// Hide all layers
LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE"
SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=YES
LAYER_LOOP_END
// Loop over the loaded layers, doing a separate export for each
LAYER_LOOP_START FILENAME="*.shp"
// Enable the current layer since we hid it above
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=NO
// Export to KML
EXPORT_VECTOR FILENAME="C:\GIS\Projekti\Divaca_Ber_10ocen_met9\T estno\script\%LAYER_FNAME_WO_EXT%.KML" TYPE=KML
// Disable the current layer so it won't be involved in other operations
SET_LAYER_OPTIONS FILENAME="%LAYER_FNAME_W_DIR%" HIDDEN=YES
LAYER_LOOP_END
// Unhide all layers
LAYER_LOOP_START FILENAME="*" VAR_NAME_PREFIX="HIDE"
SET_LAYER_OPTIONS FILENAME="%HIDE_FNAME_W_DIR%" HIDDEN=NO
LAYER_LOOP_END
Thanks,
Mike
Global Mapper Guru
geohelp@bluemarblegeo.com
Blue Marble Geographics for Coordinate Conversion, Image Reprojection and Vector Translation -
Correct. I wanto to export loaded layers.
But it seems LAYER_LOOP_START is not recognizable?
WARNING: Unknown command <LAYER_LOOP_START> ignored.
WARNING: Unknown command <SET_LAYER_OPTIONS> ignored.
WARNING: Unknown command <LAYER_LOOP_END> ignored.
WARNING: Unknown command <LAYER_LOOP_START> ignored.
WARNING: Unknown command <SET_LAYER_OPTIONS> ignored.
Don' know why. -
I had to update the program.
Now it works.
Thank you for your help and patience.
BR -
Hello,
I have tried the script, but it looks like the labels are not exported.
Is there a solution to this?
Thanks in advance,
Hayk
Categories
- 12.7K All Categories
- 5.6K Features Discussion
- 342 Downloading Imagery
- 1.3K Elevation Data
- 380 Georeferencing Imagery Discussion
- 627 GM Script Language
- 52 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