1

I have a geodataframe that has no assigned crs. I want to create a column/field called 'area' that has the area calculated as square feet, not meters or km, using geopandas. Note: this geodataframe was created by doing an attribute join between 2 previous geodataframes that had the projection: +proj=longlat +datum=WGS84 +no_defs

[38]: print(bldgs_merged.crs)
      None

Something like this:

bldgs_merged["bldg_sqft"] = bldgs_merged['geometry'].area/ 10**6

I know that the crs/projection first needs to be in a crs/projection that uses square feet. My question is, what projection do I set it to? Will WGS 84/EPSG 4326 work? Do I have to do something to set the units to be square feet?

bldgs_merged = bldgs_merged.to_crs({'init': 'epsg:4326'})
1

the area attribute of a GeoDataFrame is calculated based on projected coordinates not latitude and logitude, this means that the area you are calculating is false.

First you need to reproject the GeoDataFrame to a different CRS which units is either meter or feet, and then measure the area using areaattribute.

PS: EPSG:4326 is using degrees as units, try the EPSG:3857 which uses meters as unit or if you know the location of your polygons choose a projection from a national grid

  • Question. This seemed to work, but the calculation of the area from the geometry is returned as dtype: float with a nonsensical value like 7.338585e-09. Does this look right? How would I convert this to a 2-digit double? – gwydion93 Jul 19 at 16:44
  • 1
    @gwydion93 you can round the result to 2 digit by using a lambda function gdf['rounded_area'] = gdf['area'].apply(lambda x: round(x, 2)) – Hicham Zouarhi Jul 19 at 20:27

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.