I'm loading a layer from ArcGIS with the ArcGIS Python API:

from arcgis.features import FeatureLayer

Then I make it a pandas dataframe and then move it to Geodataframe as I saw in the documentation:

gdf=gpd.GeoDataFrame(df, crs="EPSG:3857")

The problem is I don't get the right geometry that fits my CRS. I tried using set_crs, to_crs and set it when creating gdf and nothing. It's not giving me what I need. I tried Transform as well and it works but only if i know in what crs i'm getting the layer. And it will be different layer each time

Is there a way to set it when you load the layer with 'FeatureLayer'? Or any other way to make it happen?

  • You pretty much never want to "set" a coordinate reference, since this destroys the existing CRS, and drastically increases the difficulty of working with the (now) corrupted data.
    – Vince
    Jan 16, 2022 at 17:41
  • @Vince don't have a choice, i need to get the layer geometry in the same crs i work with (3857). Got any idea?
    – Micha
    Jan 16, 2022 at 17:50
  • Are you saying the source data, what you are calling layer in your code has a different coordinate system to "EPSG:3857"?
    – Hornbydd
    Jan 16, 2022 at 17:57
  • 1
    If the geometry is not in the projection you need, project it, don't just assert that it's in the projection you want and try to work with it anyway. The single most frequent family of questions in GIS SE all has this same issue (just differeing by platform). If you have a choice of functions with "set" and "change"/"convert"/"to", don't choose "set".
    – Vince
    Jan 16, 2022 at 18:16


Your Answer

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

Browse other questions tagged or ask your own question.