Friday 19 February 2016

gdal - gdalwarp not clipping neatline properly


I have a PDF file (10mb) which contains a NEATLINE polygon in metadata.



$ gdalinfo I5601_GeoPDF.pdf


Driver: PDF/Geospatial PDF Files: I5601_GeoPDF.pdf Size is 5906, 3543 Coordinate System is: PROJCS["UTM Zone 56, Southern Hemisphere", GEOGCS["GDA94", ... GeoTransform = 128363.7573358897, 42.324133621968, 0.8865642156959999 6471730.899290663, 0.8865642156959999, -42.324133621968 Metadata: CREATION_DATE=D:20080515105609+10 CREATOR=BAE SYSTEMS MapMaker.exe 2.9.830.19227 NEATLINE=POLYGON ((191125.203093351592543 6340529.201165121048689,188350.332458852295531 6473000.141725543886423,378308.662319099530578 6476979.201503321528435,381083.532953590154648 6344508.260942890308797,191125.203093351592543 6340529.201165121048689)) ...



Now if I extract the NEATLINE data into a .cvs and use gdalwarp to cut it:


$ for i in *.pdf; do gdalinfo $i|grep NEATLINE | awk -F= '{print "id,WKT\n1,\"" $2 "\""}' > $i.csv; gdalwarp -crop_to_cutline -cutline $i.csv -overwrite $i $i.tif; done

I get a geotiff that isn't clipped correctly: picture of results


I've tried this on US 250k maps and it works. I'm wondering whether anybody can tell me if I'm doing something wrong, or is the metadata in the PDF wrong ?





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...