Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check gdalwarp using mercantile shapes --mercator (no CRS) as cutline #16

Closed
sgillies opened this issue Aug 21, 2014 · 3 comments
Closed
Labels
Milestone

Comments

@sgillies
Copy link
Contributor

Follow up from #14 (comment).

@sgillies sgillies added this to the 0.4 milestone Aug 21, 2014
@sgillies
Copy link
Contributor Author

Using the Rasterio testing data.

Cutline straight from mercantile shapes

mercantile shapes "[72, 109, 8]" --mercator \
| gdalwarp ~/code/rasterio/rasterio/tests/data/RGB.byte.tif /tmp/no_crs_72_109_8.tif -crop_to_cutline -cutline /vsistdin/ -t_srs EPSG:3857

produces a properly georeferenced but empty dataset.

Gdalwarp got the right extents from the cutline but didn't transfer any pixels.

Cutline translated by ogr2gr

mercantile shapes "[72, 109, 8]" --mercator \
| ogr2ogr /vsistdout/ /vsistdin/ -f GeoJSON -a_srs EPSG:3857 \
| gdalwarp ~/code/rasterio/rasterio/tests/data/RGB.byte.tif /tmp/72_109_8.tif -crop_to_cutline -cutline /vsistdin/ -t_srs EPSG:3857

produces a dataset with the same dimensions and extents as the one above, but with the data I expect:

72_109_8

@sgillies
Copy link
Contributor Author

Conclusion

gdalwarp doesn't need to find an SRS in a cutline datasource to crop the output to the cutline's extents, but it does need to find an SRS in the cutline in order for it to be a useful mask.

Unless you really want cutline masking, it's better to use gdalwarp --te west south east north.

I'll make sure mercantile can produce such output.

Also: support for stdin and stdout in GDAL and OGR utilities is super handy, though I wish they would support /dev/stdin and /dev/stdout on Linux.

@sgillies
Copy link
Contributor Author

The new --extents option fits into gdalwarp like this:

extent=$(mercantile shapes "[72, 109, 8]" --mercator --extents)
gdalwarp -t_srs EPSG:3857 -te $extent $source $dest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant