I am running into a warning where in performing an intersect I am getting a CRS mismatch warning

C:\OSGEO4~1\apps\Python37\lib\site-packages\geopandas\base.py:48: UserWarning: GeoSeries crs mismatch: esri:102001 and None
warn("GeoSeries crs mismatch: {0} and {1}".format(this.crs, other.crs)).

It doesn't say where the issue is taking place but the warning happens right after the print('You are here') statement. I'm not sure why I am getting the error because I am pulling both geometries from the same geoDataFrame with a defined CRS of esri:102001. When I try to set the CRS directly on each poly by adding .set_crs('esri: 102001') to the end of the polys I get

AttributeError: 'Polygon' object has no attribute 'set_crs'

sedf = pd.DataFrame({'mmsi':[getbwevals(id)[1],getbwevals(id)[1]], 'date_num':[0,9999999999], 'longitude':[getbwevals(id)[4],getbwevals(id)[6]], 'latitude':[getbwevals(id)[3],getbwevals(id)[5]]})
    aispts = gpd.GeoDataFrame((pd.DataFrame(pd.concat(dflist, ignore_index=True)[['date_num', 'mmsi', 'longitude', 'latitude']])), geometry=geopandas.array.points_from_xy((pd.DataFrame(pd.concat(dflist))).longitude, (pd.DataFrame(pd.concat(dflist))).latitude), crs=4326).to_crs('esri:102001')
    septs = gpd.GeoDataFrame(sedf, geometry=geopandas.array.points_from_xy(sedf.longitude, sedf.latitude), crs=4326).to_crs('esri:102001')
    poly1 = septs.geometry.buffer(mdist(septs)).iloc[0].set_crs('esri: 102001')
    poly2 = septs.geometry.buffer(mdist(septs)).iloc[1].set_crs('esri: 102001')
    print('You are here')
    bwe_area = gpd.GeoSeries(poly1.intersection(poly2))
    lverts = septs.append(aispts[(aispts.within(bwe_area))])

Traceback (most recent call last):
  File "...build__Track.py", line 71, in <module>
    poly1 = septs.geometry.buffer(mdist(septs)).iloc[0].set_crs('esri:102001')
AttributeError: 'Polygon' object has no attribute 'set_crs'

How do I set the CRS before running the intersect?

2 Answers 2


you can just remove the .set_crs("esri: 102001") method at the end of the poly1 and poly2 lines. You have already used the to_crs() method in the line where you use the points_from_xy() method so the polygons will be in that projection.

  • I rewrote the block so it goes step by step, with a print(var.crs) statement as I go, as soon as I create the bwe_area using bwe_area = gpd.GeoSeries(polys.iloc[0].intersection(polys.iloc[1])) the crs returns to none. When I try and make it a GeoDateFrame with geometry = 'geometry', crs = 'esri:102001' print crs still shows none.
    – MrKingsley
    Commented Jul 15, 2022 at 18:08

Shapely geometries are naive to projections/CRSs, which is why you are getting AttributeError: 'Polygon' object has no attribute 'set_crs'.

Try the following (I'm making a few guesses here at what you are trying to do):

## 1. Construct and reproject your gdf
pts = geopandas.array.points_from_xy(sedf.longitude, sedf.latitude)
septs = gpd.GeoDataFrame(sedf, geometry=pts, crs=4326).to_crs('esri:102001')

## 2. Buffer by a variable distance
import numpy as np
buff_dists = np.random.randint(10, size=septs.shape[0]) # specify what you want here for your variable buffer distance
septs['geometry'] = septs.buffer(buff_dists)

## 3. Fetch the polygons you want (now reprojected)
ix1, ix2 = 0, 1 # specify the indices you want
poly1 = septs.loc[ix1, 'geometry'] # this should be a shapely Polygon
poly2 = septs.loc[ix2, 'geometry']

## 4. Intersect geometries
intersection = poly1.intersection(poly2)
  • I added your suggestion and got the following results; using poly1 = septs.iloc[0, -1] poly2 = septs.iloc[1, -1] produced an error raise IndexingError("Too many indexers") pandas.core.indexing.IndexingError: Too many indexers dropping the -1 from the index it returns a crs mismatch. Using print(poly1.crs) shows that both polys have a none crs. I tried set_crs as outlined in the geopandas document only to get the error not attribute set_crs.
    – MrKingsley
    Commented Jul 15, 2022 at 12:30
  • Edited the answer above. You need to use both a row and column index to get an object out of the GeoDataFrame. If you use one index, you'll get a Series or GeoSeries. If you know the labeled indices in your DataFrame, it's generally a good idea to use the labeled indices with .loc rather than the positional integer indices with .iloc.
    – fishmulch
    Commented Jul 15, 2022 at 13:16
  • Still throws too many indexers errors.
    – MrKingsley
    Commented Jul 15, 2022 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.