2

I have a Geopandas Dataframe and here is the result of its SRS when I print it as WKT:

print(vector_gdf.crs.srs)

'PROJCS["RGF93_Lambert_93",
  GEOGCS["GCS_RGF93",
    DATUM["Reseau_Geodesique_Francais_1993",
      SPHEROID["GRS 1980",
        6378137,
        298.257222101,
        AUTHORITY["EPSG","7019"]],
      AUTHORITY["EPSG","6171"]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.0174532925199433],
    AUTHORITY["EPSG","4171"]],
  PROJECTION["Lambert_Conformal_Conic_2SP"],
  PARAMETER["latitude_of_origin",46.5],
  PARAMETER["central_meridian",3],
  PARAMETER["standard_parallel_1",49],
  PARAMETER["standard_parallel_2",44],
  PARAMETER["false_easting",700000],
  PARAMETER["false_northing",6600000],
  UNIT["metre",1,AUTHORITY["EPSG","9001"]],
  AXIS["Easting",EAST],
  AXIS["Northing",NORTH]]'

As you can see there are more than one AUTHORITY ID (EPSG) defined within this list of information. Which one I should take as the right one for this vector data?

I want to adapt(re-project) it based on the EPSG of the corresponding raster that I am using.

11
  • 1
    There is no authority ID defined for the PROJCS and therefore you cannot re-project based on EPSG code but probably you can use the WKT that you printed instead geopandas.org/en/stable/docs/user_guide/projections.html.
    – user30184
    Jan 27, 2022 at 12:36
  • 1
    What does crs.to_epsg() show for you?
    – user30184
    Jan 27, 2022 at 12:45
  • the crs.to_epsg() returns 2154. But as you mentioned I can not reproject it according to the EPSG of my raster which is 4326 !
    – Sinooshka
    Jan 27, 2022 at 13:28
  • 1
    I do not understand the last comment. When you re-project data you have one input crs and another crs for the output and process converts data accordingly. You can either transform your vectors into 4326 or transform your raster into 2154.
    – user30184
    Jan 27, 2022 at 13:42
  • 2
    You're not asking the question that you actually want to ask. The error is symptomatic of having some rows in the vector dataset with NULL geometries. See github.com/geopandas/geopandas/issues/511. This can be fixed (NULLs dropped) with df = df[df.geometry.notnull()]. The original question should be closed, or else the extraneous information (why you want to know the CRS and what else you want to do with it) should be removed, and the correct answer given by @IanTurton should be selected. Jan 28, 2022 at 5:47

2 Answers 2

5

EPSG codes don't just define CRS, which is I think what you are seeking here. In your example none of the EPSG authority codes using in the WKT describe the CRS and GIS applications that parse the WKT shouldn't need it.

The official EPSG registry to check on the codes is https://epsg.org/home.html

A search for just RGF93 returns 50 CRS, including

RGF93 v1 / Lambert-93 ~ CODE:   2154

RGF93 v2 / Lambert-93 ~ CODE:   9793

RGF93 v2b / Lambert-93 ~ CODE:  9794
2
  • Thank you very much. It is very confusing to be true. When I try to get the EPSG code of my "raster" using rasterio I get a clear 4 digit integer :EPSG4326. With the WKT produced from the Geopandas Dataframe (of the shapefile) I have to first guess which one is the correct SRS ID and if I want to reproject the vector data based on the raster what should I do?! At this step I try to do vector:_gdf.to_crs(epsg=raster_epsg) but it generates an Error : AttributeError: 'NoneType' object has no attribute 'is_empty'. When I check the fields of my .shp file there are no missing geometry!
    – Sinooshka
    Jan 27, 2022 at 12:23
  • 4
    There is no need to guess because the WKT is well defined and crs.to_epsg() can show you the corresponding EPSG code.
    – user30184
    Jan 27, 2022 at 13:44
4

Goto http://epsg.io and search for rgf93 lambert 93 and you will find epsg:2154:

PROJCS["RGF93 / Lambert-93",
    GEOGCS["RGF93",
        DATUM["Reseau_Geodesique_Francais_1993",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6171"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4171"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",49],
    PARAMETER["standard_parallel_2",44],
    PARAMETER["latitude_of_origin",46.5],
    PARAMETER["central_meridian",3],
    PARAMETER["false_easting",700000],
    PARAMETER["false_northing",6600000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    AUTHORITY["EPSG","2154"]]

You can always see which "AUTHORITY" code goes with which element as they are contained in the [].

5
  • This is the right answer, but more explanation is necessary. OP is only interested in which EPSG code applies to the projected coordinate system, and it is the last one. Some explanation of the other authority codes and the element they apply to would be helpful, e.g. AUTHORITY["EPSG","9001"] applies to the UNIT element. Jan 28, 2022 at 5:19
  • look at the containing square brackets - this is obvious to me
    – Ian Turton
    Jan 28, 2022 at 9:50
  • I think that with PROJCS/GEOGCS it is not so obvious for beginners because the title is first in the WKT and corresponding code last, and like in the WKT in the question, just the PROJCS authority code is often missing, even WKT contains codes for degree, metre, and so on.
    – user30184
    Jan 28, 2022 at 13:25
  • @IanTurton I reformatted OP's question. Notice that what they posted is missing the final authority. Did OP just copy it incorrectly? Was it missing from their results? If they look at the WKT string they posted, they will be unable to determine the authority. You posted what appears to be the correct WKT, but why is theirs different? More explanation to unpack this for someone less knowledgeable would make this a more useful answer for OP and other people who find this Q&A. Jan 29, 2022 at 19:44
  • @LeeHachadoorian: I know it was missing, that is why I showed how to find the epsg code via epsg.io and to thus find the correct WKT with the authority
    – Ian Turton
    Jan 30, 2022 at 10:42

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.