TransWikia.com

gdalwarp leaves black boundary of cropped GeoTIFF with cutline

Geographic Information Systems Asked by bakerjw on August 4, 2020

This is a new question based on a response on the thread white page border when converting geoPDF to geoTiff with gdal_translate

I am using gdalwarp as described to do a cutline of GeoTIFF images that have been rendered from geospatial PDFs. The neatline in the PDFs is not accurate but I can easily create UTM coordinates and adjust them accordingly to get the GeoTIFF image that I desire.

This is the CSV file. The coordinates are not square

id,WKT
1,"POLYGON ((410290.5552 4025996.01,410434.6684 4039895.26,421656.358 4039786.037,421530.3048 4025886.935,410290.5552 4025996.01))"

This is the command line:

gdalwarp original.tif original.crop.tif -cutline mycutline.csv -crop_to_cutline

The new image is square and the cropped image is canted inside as is expected. The problem is that the outer crop area is showing up as black. When I tile the image and display it on top of a map base layer, it aligns perfectly except that it has a black edge around it. If the edging was transparent then it would be fine, but the when tiled, it definitely retains the black color.

Here is a sample image
http://www.appalachianbiketrails.org/images/resized.tif

Here is the tile example
http://www.appalachianbiketrails.org/tiles/openlayers.html

I have tried adding the -dstalpha flag as mentioned in other posts and shown in the code snippet below, but that gives the error “Cannot compute bounding box of cutline.”

gdalwarp original.tif original.crop.tif -cutline mycutline.csv -crop_to_cutline -dstalpha

On a side note, I found that the direction of the coordinates in my CSV file determined whether the crop was inside or outside of the coordinates.

One Answer

For those finding this via search, note the NEATLINE (as obtained from gdalinfo) in many (all?) USGS quad PDFs are incorrect, being larger than the correct NEATLINE (still true in 2020 as of this post). Is why above did not work.

Answered by Jack G on August 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP