Changes between Version 4 and Version 5 of USGS_PDF_Topo


Ignore:
Timestamp:
Jan 28, 2013, 11:34:04 AM (11 years ago)
Author:
EliL
Comment:

add python script from list

Legend:

Unmodified
Added
Removed
Modified
  • USGS_PDF_Topo

    v4 v5  
    11= Summary =
    22
    3 1. USGS offers new topo maps as a geospatial PDF [http://www.gdal.org/frmt_pdf.html] for download [http://nationalmap.gov/ustopo/index.html].  Direct download of specific file: [http://ims.er.usgs.gov/gda_services/download?item_id=5365522]
    4 2. Some users may prefer to have the Topo map as a geotif rather than PDF
     3* USGS offers new topo maps as a geospatial PDF [http://www.gdal.org/frmt_pdf.html] for download [http://nationalmap.gov/ustopo/index.html].  Direct download of specific file: [http://ims.er.usgs.gov/gda_services/download?item_id=5365522]
     4
     5* Some users may prefer to have the Topo map as a geotif rather than PDF
     6
     7* Here are some tips to convert PDFs (specifically USGS Topo maps) to geotif
    58
    69= Details =
    710
    8 1. GDAL must be built with Geospatial PDF support, see the above link for details.  Confirm with:
     11GDAL must be built with Geospatial PDF support, see the above link for details.  Confirm with:
    912{{{
    1013$ gdalinfo --formats
     
    1720}}}
    1821
    19 2. Use gdalinfo to get NEATLINE:
     22== python script ==
     23
     24This cutline.py python script was recommended on the email [http://lists.osgeo.org/pipermail/gdal-dev/2013-January/035269.html list]. 
     25
     26{{{
     27from osgeo import gdal
     28import os
     29import sys
     30
     31ds = gdal.Open(sys.argv[1])
     32neatline_wkt = ds.GetMetadataItem("NEATLINE")
     33ds = None
     34
     35f = open('cutline.csv', 'wt')
     36f.write('id,WKT\n')
     37f.write('1,"%s"\n' % neatline_wkt)
     38f.close()
     39
     40os.system('gdalwarp %s %s.tif ' % (sys.argv[1], sys.argv[1]) +
     41          '-crop_to_cutline -cutline cutline.csv -overwrite')
     42}}}
     43
     44Usage: python cutline.py your.pdf
     45
     46== Manual method ==
     47
     48If you for some reasons want to do things more manually, here is how:
     49
     501. Use gdalinfo to get NEATLINE:
    2051{{{
    2152$gdalinfo OR_Newport_North_20110824_TM_geo.pdf
     
    2960}}}
    3061
    31 3. Make an OGR datasource of the NEATLINE to use as a cutline in gdalwarp.  This can be two files, a .vrt and .csv
     622. Make an OGR datasource of the NEATLINE to use as a cutline in gdalwarp.  This can be two files, a .vrt and .csv
    3263wkt_cutline_file.vrt:
    3364{{{
     
    4980}}}
    5081
    51 4. Use gdal_translate or gdalwarp to convert to geotif and if using gdalwarp, -cutline to the NEATLINE.
     823. Use gdal_translate or gdalwarp to convert to geotif and if using gdalwarp, -cutline to the NEATLINE.
    5283{{{
    5384gdalwarp -cutline wkt_cutline_file.vrt -cl NEATLINE -crop_to_cutline OR_Newport_North_20110824_TM_geo.pdf OR_Newport_North_20110824_TM_geo.tif
     
    5687
    5788= Notes =
    58  * There is probably a more elegant way to grab the NEATLINE for use.  (see this thread for some ideas, [http://osgeo-org.1803224.n2.nabble.com/gdal-dev-GeoPDF-translation-td7091018.html GeoPDF thread on nabble])
     89 * There is probably a more elegant way to grab the NEATLINE for use.  (see this thread for some ideas, [http://osgeo-org.1803224.n2.nabble.com/gdal-dev-GeoPDF-translation-td7091018.html GeoPDF thread on nabble]).  The above python script does this. 
    5990 * This could be combined with gdalinfo, wget, or curl to determine which file to download.  (This is not the same file listed above but a nearby historical Topo)
    6091{{{