Interpreting GeoPandas Polygon coordinates

Viewed 163

This official example on GeoPandas website here displays a sample geopandas dataframe with geometry column containing POLYGON with coordinates:

               BoroName     Shape_Leng    Shape_Area  \
BoroCode
1             Manhattan  359299.096471  6.364715e+08
2                 Bronx  464392.991824  1.186925e+09
3              Brooklyn  741080.523166  1.937479e+09
4                Queens  896344.047763  3.045213e+09
5         Staten Island  330470.010332  1.623820e+09

                                                   geometry
BoroCode
1         MULTIPOLYGON (((981219.0557861328 188655.31579...
2         MULTIPOLYGON (((1012821.805786133 229228.26458...
3         MULTIPOLYGON (((1021176.479003906 151374.79699...
4         MULTIPOLYGON (((1029606.076599121 156073.81420...
5         MULTIPOLYGON (((970217.0223999023 145643.33221...

I am new to GeoPandas. I thought the coordinates should follow GIS standards for GPS. If so, why are these coordinates so large (in millions). Are they scaled up in some way? If someone could explain, thanks.

1 Answers

This GeoDataFrame has spatial data which is projected onto a specific coordinate reference system (CRS) which is not lat/lon. Latitude and Longitude coordinates need a specific definition of the shape of the earth and reference zero-points - one which is most commonly accepted as the standard is World Geodetic System 1984 (aka WGS84 aka EPSG:4326). Many times, when you load a shapefile, the data will be encoded as lat/lon using WGS84. But not always.

The .crs attribute of a GeoDataFrame or GeoSeries gives more information about the specific reference system used in encoding the data. In the case of this example:

In [3]: nybb_path = geopandas.datasets.get_path('nybb')
   ...: boros = geopandas.read_file(nybb_path)
   ...: boros.set_index('BoroCode', inplace=True)
   ...: boros.sort_index(inplace=True)
   ...: 

In [4]: boros.crs
Out[4]:
<Derived Projected CRS: EPSG:2263>
Name: NAD83 / New York Long Island (ftUS)
Axis Info [cartesian]:
- X[east]: Easting (US survey foot)
- Y[north]: Northing (US survey foot)
Area of Use:
- name: United States (USA) - New York - counties of Bronx; Kings; Nassau; New York; Queens; Richmond; Suffolk.
- bounds: (-74.26, 40.47, -71.8, 41.3)
Coordinate Operation:
- name: SPCS83 New York Long Island zone (US Survey feet)
- method: Lambert Conic Conformal (2SP)
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

You can see that the coordinates in this dataset are in units of US survey feet referenced to the North American Datum 1983 (NAD83) (hence the large values), and are projected using a Lambert Conic Conformal (2SP) projection. This projection has advantages for mapping because, unlike an equi-rectangular projection, e.g. simply mapping lat/lon to pixels, a conformal projection will preserve angles (so e.g. street corners will look like right angles regardless of latitude).

You can change the projection using geopandas.GeoDataFrame.to_crs. GeoPandas uses pyproj to manage projections - the proj syntax for WGS84 is "epsg:4326":

In [5]: boros_latlon = boros.to_crs('epsg:4326')

In [6]: boros_latlon.crs
Out[6]: 
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

Now, the shapes are expressed as lat/lon

In [7]: boros_latlon
Out[7]: 
               BoroName     Shape_Leng    Shape_Area  \
BoroCode                                               
1             Manhattan  359299.096471  6.364715e+08   
2                 Bronx  464392.991824  1.186925e+09   
3              Brooklyn  741080.523166  1.937479e+09   
4                Queens  896344.047763  3.045213e+09   
5         Staten Island  330470.010332  1.623820e+09   

                                                   geometry  
BoroCode                                                     
1         MULTIPOLYGON (((-74.01093 40.68449, -74.01193 ...  
2         MULTIPOLYGON (((-73.89681 40.79581, -73.89694 ...  
3         MULTIPOLYGON (((-73.86706 40.58209, -73.86769 ...  
4         MULTIPOLYGON (((-73.83668 40.59495, -73.83678 ...  
5         MULTIPOLYGON (((-74.05051 40.56642, -74.05047 ... 

See the geopandas guide to projections and coordinate reference systems for more information.

Related