Skip to content

arthur-e/gdal_extent.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

gdal_extent.py

A command-line utility for getting the extent (bounds) of any raster as Well-Known Text (WKT), GeoJSON, or other vector formats. It is intended to compliment the library of GDAL utilities already available.

Utilities

Default behavior at CLI; to get the rectangular extent of a raster in the format expected by other GDAL utiltiies, e.g., the -te switch with gdal_rasterize:

$ ./gdal_extent.py Wayne_county.tiff
289965.0 4655115.0 346215.0 4701645.0

To get the width/height of a raster:

$ ./gdal_extent.py --size Wayne_county.tiff
1875 1551

To get a GeoJSON Polygon for the rectangular extent as a string, with 2 spaces for indentation:

$ ./gdal_extent.py --extent --as-json -i 2 Wayne_county.tiff
{
  "coordinates": [
    [
      [
        289965.0,
        4701645.0
      ],
      [
        346215.0,
        4701645.0
      ],
      [
        346215.0,
        4655115.0
      ],
      [
        289965.0,
        4655115.0
      ],
      [
        289965.0,
        4701645.0
      ]
    ]
  ],
  "type": "Polygon"
}

About

A command line utility for getting the extent (bounds) of a raster

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages