0

I am trying to unify the geosystem of a shp file and a DEM file. I tried to use rasterstats.zonal_stats to find the overlap between these two data but it returns None. So I assume there is some problem with the geo system.

I printed the shp file crs by using geopandas. The crs shows

<Projected CRS: EPSG:26917>
Name: NAD83 / UTM zone 17N
Axis Info [cartesian]:
- E[east]: Easting (metre)
- N[north]: Northing (metre)
Area of Use:
- name: North America - between 84°W and 78°W - onshore and offshore. Canada - Nunavut; Ontario; Quebec. United States (USA) - Florida; Georgia; Kentucky; Maryland; Michigan; New York; North Carolina; Ohio; Pennsylvania; South Carolina; Tennessee; Virginia; West Virginia.
- bounds: (-84.0, 23.81, -78.0, 84.0)
Coordinate Operation:
- name: UTM zone 17N
- method: Transverse Mercator
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

The crs of the DEM file is got by rasterio, it shows the crs is

CRS.from_epsg(26917)

It looks like both two files are using CRS 26917. But when I plot the two files. The x axile of the shp file is from -81.9 to -81.5. The x axile of the DEM file is from 420000 to 500000. So there must be something wrong about the geo system.

How should I unify this two so I can plot them in the same picture and do rasterstats.zonal_stats?

Xudong
  • 441
  • 5
  • 16

1 Answers1

1

Reprojecting the raster is more complicated than changing the crs of the geometry in geopandas; Therefore, if you know the crs of the DEM, it may be faster to change the crs of the shp file. gdf.to_crs(raster_crs)

If the CRS of the DEM is unknown, it should be prioritized to find the correct CRS using the TSM of QGIS. (After displaying an online map such as OSM, input the raster and make sure it represents the correct location.)

The next thing you will do is clip the raster using shp. When working with raster, this is called MASK. Please refer to the following link.

https://rasterio.readthedocs.io/en/latest/topics/masking-by-shapefile.html

Urban87
  • 243
  • 1
  • 8