How can I limit the import bounds of a Spatial_DB table?

gghigginigghiggini Global Mapper UserPosts: 9
I have very large tables in a POSTGIS database.

I tried limit the import with my Script (using GM 16.2) as follow:
-----------------------------------------------------------------
DIR_LOOP_START DIRECTORY="%MYDIR%" FILENAME_MASKS="*.shp *.SHP" RECURSE_DIR=YES

    // Import a SHP
        IMPORT FILENAME="%FNAME_W_DIR%" TYPE=SHAPEFILE ELEV_UNITS="METERS" PROJ='EPSG:900913'
   
    IMPORT_SPATIAL_DB TYPE="POSTGIS" SDB_CONNECTION_NAME="NOAA2" \
           SDB_TABLE_NAME="public.depcnt_l" LAYER_BOUNDS="%FNAME_W_DIR%"

    // Export the loaded file into Shapefile
    EXPORT_VECTOR FILENAME="%DIR%\%FNAME_WO_EXT%\depcnt.shp" TYPE=SHAPEFILE SHAPE_TYPE=LINES INC_LAYER_ATTR=NO GEN_PRJ_FILE=YES
       
    // Unload the loaded data
    UNLOAD_ALL

// End the loop
DIR_LOOP_END
-----------------------------------------------------------------

But GM imports the whole depcnt_l table.

Any help is very appreciated.

Best regards,
Giorgio

Best Answer

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 2,026
    Answer ✓
    You can now use the following parameters to limit the import bounds on the IMPORT_SPATIAL_DB command:
    • LAT_LON_BOUNDS - specifies the bounds to import in latitude/longitude degrees relative to the WGS84 datum. There should be 4 values in a comma-delimited list following the parameter name. The values should be in order of westmost longitude, southernmost latitude, easternmost longitude, northernmost latitude.
    • LAYER_BOUNDS - specifies that the import should use the bounds of the loaded layer(s) with the given filename. For example, to import to the bounds of the file "c:\test.tif", you would use LAYER_BOUNDS="c:\test.tif". Keep in mind that the file must be currently loaded.
    • LAYER_BOUNDS_EXPAND - specifies that the operation should expand the used LAYER_BOUNDS bounding box by some amount. The amount to expand the bounding rectangle by should be specified in the current global projection. For example, if you have a UTM/meters projection active and want to expand the bounds retrieved from the LAYER_BOUNDS parameter by 100 meters on the left and right, and 50 meters on the top and bottom, you could use LAYER_BOUNDS_EXPAND="100.0,50.0". You can also specify a single value to apply to all 4 sides, or supply 4 separate values in the order left,top,right,bottom.
    I have placed new builds with the latest changes at http://data.bluemarblegeo.com/downloads/global-mapper/dailybuilds/. Simply download the appropriate installer and run it to install the latest build.

    gghiggini

Answers

  • bmg_bobbmg_bob Global Mapper Programmer Posts: 2,026
    IMPORT_SPATIAL_DB uses a parameter called SDB_IMPORT_BOUNDS.  The parameter value is a bounding rectangle in the same projection as the import database, in the form: "<minX>,<minY>,<maxX>,<maxY>".

    Example: SDB_IMPORT_BOUNDS="-126.821609,26.773888,-106.597575,50.302504".

    It appears that the description for this parameter did not make it into the documentation.  
  • gghigginigghiggini Global Mapper User Posts: 9
    Thank you.
    So it seems not possible to pass a pre-loaded layer name as LAYER_BOUNDS, right ?

    thanks for your help
    Giorgio
  • bmg_bobbmg_bob Global Mapper Programmer Posts: 2,026
    That is correct.  I have added feature request #17302 to our task list so we can evaluate adding LAYER_BOUNDS to the IMPORT_SPATIAL_DB command.  We will post a message on this thread when the status of this feature request changes.
Sign In or Register to comment.