Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork967
Python tools for geographic data
License
geopandas/geopandas
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python tools for geographic data
GeoPandas is a project to add support for geographic data topandas objects. It currently implementsGeoSeries
andGeoDataFrame
types which are subclasses ofpandas.Series
andpandas.DataFrame
respectively. GeoPandasobjects can act onshapelygeometry objects and perform geometric operations.
GeoPandas geometry operations are cartesian. The coordinate referencesystem (crs) can be stored as an attribute on an object, and isautomatically set when loading from a file. Objects may betransformed to new coordinate systems with theto_crs()
method.There is currently no enforcement of like coordinates for operations,but that may change in the future.
Documentation is available atgeopandas.org(current release) andRead the Docs(release and development versions).
The GeoPandas project uses anopen governance modeland is fiscally sponsored byNumFOCUS. Consider makingatax-deductible donation to help the projectpay for developer time, professional services, travel, workshops, and a variety of other needs.
See theinstallation docsfor all details. GeoPandas depends on the following packages:
pandas
shapely
pyogrio
pyproj
packaging
Further,matplotlib
is an optional dependency, required for plotting.Those packages depend on several low-level libraries for geospatial analysis, which can be a challenge to install. Therefore, we recommend to install GeoPandas using theconda package manager. See theinstallation docs for more details.
- Ask usage questions ("How do I?") onStackOverflow orGIS StackExchange.
- Get involved indiscussions on GitHub
- Report bugs, suggest features or view the source codeon GitHub.
- For a quick question about a bug report or feature request, or Pull Request, head over to thegitter channel.
- For less well defined questions or ideas, or to announce other projects of interest to GeoPandas users, ... use themailing list.
>>> import geopandas>>> from shapely.geometry import Polygon>>> p1 = Polygon([(0, 0), (1, 0), (1, 1)])>>> p2 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])>>> p3 = Polygon([(2, 0), (3, 0), (3, 1), (2, 1)])>>> g = geopandas.GeoSeries([p1, p2, p3])>>> g0 POLYGON ((0 0, 1 0, 1 1, 0 0))1 POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))2 POLYGON ((2 0, 3 0, 3 1, 2 1, 2 0))dtype: geometry
Some geographic operations return normal pandas objects. Thearea
property of aGeoSeries
will return apandas.Series
containing the area of each item in theGeoSeries
:
>>> print(g.area)0 0.51 1.02 1.0dtype: float64
Other operations return GeoPandas objects:
>>> g.buffer(0.5)0 POLYGON ((-0.3535533905932737 0.35355339059327...1 POLYGON ((-0.5 0, -0.5 1, -0.4975923633360985 ...2 POLYGON ((1.5 0, 1.5 1, 1.502407636663901 1.04...dtype: geometry
GeoPandas objects also know how to plot themselves. GeoPandas usesmatplotlib for plotting. To generate a plot of aGeoSeries
, use:
>>> g.plot()
GeoPandas also implements alternate constructors that can read any data format recognized bypyogrio. To read a zip file containing an ESRI shapefile with theboroughs boundaries of New York City (the example can be fetched using thegeodatasets
package):
>>> import geodatasets>>> nybb_path = geodatasets.get_path('nybb')>>> boros = geopandas.read_file(nybb_path)>>> boros.set_index('BoroCode', inplace=True)>>> boros.sort_index(inplace=True)>>> boros BoroName Shape_Leng Shape_Area \BoroCode1 Manhattan 359299.096471 6.364715e+082 Bronx 464392.991824 1.186925e+093 Brooklyn 741080.523166 1.937479e+094 Queens 896344.047763 3.045213e+095 Staten Island 330470.010332 1.623820e+09 geometryBoroCode1 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...
>>> boros['geometry'].convex_hullBoroCode1 POLYGON ((977855.4451904297 188082.3223876953,...2 POLYGON ((1017949.977600098 225426.8845825195,...3 POLYGON ((988872.8212280273 146772.0317993164,...4 POLYGON ((1000721.531799316 136681.776184082, ...5 POLYGON ((915517.6877458114 120121.8812543372,...dtype: geometry
About
Python tools for geographic data
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.