Global Mapper v25.0

SHP to SPATIALITE batch

946
946 Global Mapper UserTrusted User
edited December 2014 in Technical Support
Hi there,

Is there a way to convert shp files to spatialite db? I ll need to have one spatialite for each shp .

Thanks,
Remi

Comments

  • PShorey
    PShorey Global Mapper Developer Moderator, Trusted User
    edited December 2014
    Hi Remi,

    We can export vector data to a spatialite DB, but not as a batch conversion. I believe you could write a script to to this however:
    Global Mapper Scripting Reference
  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited December 2014
    Hi Remi,

    Here is a sample script that provides a basic outline for you to use:
    GLOBAL_MAPPER_SCRIPT VERSION=1.00
    SET_LOG_FILE="C:\DATA\CONVERT.LOG"
    UNLOAD_ALL
    
    // Loop over all shapefiles in a folder and convert them
    DIR_LOOP_START DIRECTORY="C:\DATA\SHP\" FILENAME_MASKS="*.shp" RECURSE_DIR=NO
    
        // Import a shapefile.
        IMPORT FILENAME="%FNAME_W_DIR%" TYPE=SHAPEFILE
    
        // Export the data to a Spatialiate database.
        EXPORT_VECTOR FILENAME="%DIR%%FNAME_WO_EXT%_OUT.sqlite" TYPE=SPATIALITE \
                          SDB_TABLE_NAME=%FNAME_WO_EXT% 
    
        // Unload the loaded data
        UNLOAD_ALL
    
    // End the loop
    DIR_LOOP_END
    

    Cheers,

    Bob
  • 946
    946 Global Mapper User Trusted User
    edited December 2014
    Thanks Bob!
    All the best