I have a Sentinel 2A scene (downloaded from Sentinel AWS storage in UTM projection) and coordinates (a polygon of lat/lng) of a specific plot of land. How can I extract a piece corresponding to that field (preferably in EPSG 3857, so that I could overlay it on Google Maps) a piece corresponding to my plot of interest (or to a given Google Maps tile), using either Python or CLI tools?

I have used gdalwarp to transform the scene image to EPSG:3857, but how can I then transform the lat/lng coordinates of my plot's borders (or the given tile's borders) to the coordinates of the pixels I need to crop? Are there any ready-made utilities or libraries for that?

  • What format is your "polygon of lat/lng" in? Do you simply have a set of coordinates, or do you have a shp / kml / kmz? Jun 6 '17 at 11:42

If you have a rectangle bounding box you want to cut, you can use gdalwarp function with target extents (-te) and target extent srs (-te_srs) :

-te xmin ymin xmax ymax: set georeferenced extents of output file to be created (in target SRS by default, or in the SRS specified with -te_srs)

-te_srs srs_def: (GDAL >= 2.0) Specifies the SRS in which to interpret the coordinates given with -te. The srs_def may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file containing the WKT. This must not be confused with -t_srs which is the target SRS of the output dataset. -te_srs is a convenience e.g. when knowing the output coordinates in a geodetic long/lat SRS, but still wanting a result in a projected coordinate system.

For example:

gdalwarp -te 10 40 15 45 -te_srs EPSG:4326 -t_srs EPSG:3857 infile outfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.