# GeoPandas GeoDataFrame polygon geometry - calculate area

I have a geopandas GeoDataFrame with Polygon geometry and I am calculating the area of the polygon, however, I am not sure what the unit is for the area.

``````import geopandas as gpd
from shapely.geometry import Polygon

# create two dummy polygons
poly1 = Polygon([(35.8,-98.666), (35.81,-98.656), (35.822,-98.662), (35.824,-98.678)])
poly2 = Polygon([(35.527,-98.709), (35.537,-98.699), (35.55,-98.706), (35.552,-98.722)])

# create a geopandas DataFrame with two rows
data = {'name': ['Polygon 1', 'Polygon 2'], 'geometry': [poly1, poly2]}
df = gpd.GeoDataFrame(data, crs='EPSG:4326')
``````

I'd like to reproject the geometry and calculate the area in square meters or another linear unit, however, I have been having issues with re-projection and transforming geometries:

`````` `df['geometry'][0].area`
``````

when I attempt to convert the `crs` to a `projected coordinate reference` system, I get `Polygon (Inf Inf....)`.

``````df.to_crs('EPSG:32610', inplace=True)
df.crs
``````

Expected output is to calculate the `area()` in `square meters` units.

• Does this answer help? Are you sure your input coordinates are long/lat? May 3, 2023 at 1:46
• Why would you expect that to work? Your dummy coordinates are nowhere near your UTM Zone. Try dummy coords actually in UTM zone 10N like `poly1 = Polygon([(-125,49), (-124,49), (-124,50), (-125,50)])`. Or provide us with some actual data so we can test and replicate. May 3, 2023 at 3:48
• Does this answer your question? Calculating the Area by Square Feet with Geopandas
– gene
May 3, 2023 at 9:05
• Or project into EPSG:32631 (WGS 84 / UTM zone 31 North) where your test latitudes and longitudes would fall. May 3, 2023 at 12:33
• @user2856 I have updated the post with some actual data. The geometries represent locations in Texas.
– kms
May 3, 2023 at 16:45

Have you reversed lat and long? If you swap them it works:

``````import geopandas as gpd
from shapely.geometry import Polygon

coords1 = [(35.8,-98.666), (35.81,-98.656), (35.822,-98.662), (35.824,-98.678)]
coords1 = [x[::-1] for x in coords1] #Reverse lat lon
#[(-98.666, 35.8), (-98.656, 35.81), (-98.662, 35.822), (-98.678, 35.824)]

coords2 = [(35.527,-98.709), (35.537,-98.699), (35.55,-98.706), (35.552,-98.722)]
coords2 = [x[::-1] for x in coords2]

poly1 = Polygon(coords1)
poly2= Polygon(coords2)

data = {'name': ['Polygon 1', 'Polygon 2'], 'geometry': [poly1, poly2]}
df = gpd.GeoDataFrame(data, crs='EPSG:4326')
df.apply(lambda x: x.geometry.is_valid, axis=1)
#0    True
#1    True

df = df.to_crs(epsg=26915)
df.apply(lambda x: x.geometry.is_valid, axis=1)
# 0    True #Both were invalid with your original coordinates
# 1    True

df["area_m2"] = df.geometry.area
# 0    2.722672e+06
# 1    2.904215e+06
``````

• I swapped the axes to `long, lat` ...`POLYGON ((-97.489 28.834, -97.479 28.844, -97....` and then `gdf.geometry.area`, I am still not seeing the values in `square meters`. The `crs` of the `geoDataFrame` is `Projected CRS: EPSG:26915`
– kms
May 4, 2023 at 18:45
• I get approximately `0.000570` when running `.area()` method on `geometry` column.
– kms
May 4, 2023 at 21:26