I have two elements - geo_df - a set of Points identifying different assets and a raster (grid) where each grid/pixel has an associated value.

How do I overlay the points from the dataset upon the grid to get either the column/row index or the lat/long index of the vertices of the pixel?

This is what I have:

import rasterio
import geopandas

data_set = [['Site 1', 14.207355,40.840481], ['Site 2', 14.0743, 41.1552]]
df = pd.DataFrame(data_set, columns = ["Name", 'Latitude', 'Longitude'])
crs = {'init': 'epsg:4326'} 
geo_df = GeoDataFrame(df, crs=crs, geometry=geometry)

file = r'~raster.tif'
with rasterio.open(file, 'r+') as rds:
    rds.crs = CRS.from_epsg(4326)
    fig, ax = plt.subplots(figsize=(15, 15))
    plt.imshow(rds.read(1), cmap='Reds')
  • Can you add an illustration? I don't understand if your points match the center of the raster pixels or if they are unrelated. Are you trying to a) know the coordinates of your points (in which case the info should be in your geodatabase)? Or b) extract the raster info for each point?
    – ChloeG
    Mar 24 at 10:08

1 Answer 1


Plot shapefile over raster

import rasterio
import rasterio.plot
import geopandas as gpd
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(10, 10))
rasterio.plot.show(rds, ax=ax, cmap='Reds')

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.