2

I have an elevation file (.tif) in EPSG:4326 and point data for wildfire occurrence in the same projection. When I use this projection, I can use the following code to extract the elevation value, for the corresponding point and add that into the dataframe:

wfdf=gpd.read_file('wildfire_all_1980_2016_gdb/wf_all_1980_2016_clip.shp')
elev=rasterio.open('elevation/elevhillshade.tif')

fig, ax=plt.subplots(figsize=(12,12))
wfdf.plot(ax=ax, color='orangered', alpha=0.5)
show(elev, ax=ax)

coords = [(x,y) for x, y in zip(wfdf.DLONGITUDE, wfdf.DLATITUDE)] 
wfdf['Elevation'] = [x[0] for x in elev.sample(coords)]
wfdf

However, I need this in EPSG:26912 to be more accurately represented. I have tried to reproject both layers into EPSG:26912, but then the elevation values just result in my default NoData value -9999 for every point. So I then created a whole new raster for elevation, already in the correct projection, using mosaic tool in ArcGIS. I checked in the software, and there were no NoData values, the raster is all good. However, same thing happens - I read it in, I reproject the wfdf fire occurrence point data to EPSG:26912 as so:

wfdf=wfdf.to_crs(epsg=26912)

I run the same code, and again, all values for Elevation are -9999. It only seems to read data values in the EPSG:4326 and I cannot find a solution online.

If I run the Extract Values to Points in ArcGIS for the correct coordinate system, it works also, so it's something happening in Python.

Your Answer

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

Browse other questions tagged or ask your own question.