[gdal-dev] Clip tiff with shapefile

Paul Meems bontepaarden at gmail.com
Mon Jun 12 07:14:21 PDT 2017


Hi,

I'm trying to clip a tiff-file with a shapefile.
I'm using GDAL v2.1.3 with the SWIG-bindings in my C# application.

The tiff-file has this info:
Driver: GTiff/GeoTIFF
Files:
Size is 5140, 6065
Coordinate System is:
PROJCS["WGS 84 / UTM zone 32N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32632"]]
Origin = (360810.191610000040000,5860662.620930000200000)
Pixel Size = (0.125010000000000,-0.125010000000000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_SOFTWARE=pix4dmapper
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  360810.192, 5860662.621) (  6d55'54.04"E, 52d52'39.50"N)
Lower Left  (  360810.192, 5859904.435) (  6d55'55.21"E, 52d52'14.98"N)
Upper Right (  361452.743, 5860662.621) (  6d56'28.39"E, 52d52'40.10"N)
Lower Right (  361452.743, 5859904.435) (  6d56'29.55"E, 52d52'15.58"N)
Center      (  361131.467, 5860283.528) (  6d56'11.80"E, 52d52'27.54"N)
Band 1 Block=256x256 Type=Float32, ColorInterp=Gray
  Min=-0.177 Max=33.644
  Minimum=-0.177, Maximum=33.644, Mean=18.605, StdDev=7.894
  NoData Value=-10000
  Metadata:
    STATISTICS_MAXIMUM=33.644180297852
    STATISTICS_MEAN=18.604999564386
    STATISTICS_MINIMUM=-0.17713606357574
    STATISTICS_STDDEV=7.8939827089249

The border can be in a different projection. Because I create this file
earlier I know its EPSG-code.
Before clipping I want to check if both files are in the same projection.
How can I do this? I know I can use SpatialReference. But how to convert
the projection string in the metadata of my tiff to EPSG code?
If they have different projections I need to reproject my border shapefile
first using VectorTranslate.

I was think of using these options:
var options = new[]
{
    "-s_srs", "EPSG:" + sridInput,
    "-t_srs", "EPSG:" + sridOutput,
    "-f", "ESRI Shapefile"
};
VectorTranslate(input, output, options);

But then I need to get the EPSG code of the tiff file.

Please advice.

Thanks,

Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170612/1fa6a913/attachment-0001.html>


More information about the gdal-dev mailing list