Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mapping packages Unfortunately none come with Anaconda (only geoprocessing is http://proj4.org/ which does lat/long to Cartesian conversions). matplotlib.

Similar presentations


Presentation on theme: "Mapping packages Unfortunately none come with Anaconda (only geoprocessing is http://proj4.org/ which does lat/long to Cartesian conversions). matplotlib."— Presentation transcript:

1 Mapping packages Unfortunately none come with Anaconda (only geoprocessing is which does lat/long to Cartesian conversions). matplotlib integrates with basemap: But tricky to get working well. And cartopy for more sophisticated vector graphics: GeoPandas probably the simplest to use: Based on Shapely , which has its roots in PostGIS. There are a wide variety of mapping packages for Python. Unfortunately none of them come with Anaconda, but if you have your own machine you can install them. While matplotlib has a couple of spin-off packages, most notably basemap, these can be hard to get working, especially on windows with the latest version of Python. Better is geopandas, which works well and is easy to get running. GeoPandas is based on Shapely, a package for generic shape manipulation and plotting in arbitrary coordinate spaces. This ultimately has its roots in the PostGIS spatial database.

2 GeoPandas Based around GeoSeries and GeoDataFrames. These made of:
Points / Multi-Points Lines / Multi-Lines Polygons / Multi-Polygons GeoDataFrames always have one geometry column (by default called "geometry"). This can be set/get with: gdf = gdf.set_geometry('col1') print(gdf.geometry.name) GeoPandas basically adds the "geo" to the pandas series and dataframes setup. It does this by including a geometry column containing geographical data.

3 I/O Wide range of filetypes importable with:
gdf = geopandas.read_file("filename") Including shapefiles and GeoJSON. Can also use a URL string. To write, use: gdf.to_file() Supports a wide range of formats (underneath uses fiona: see manual for supported formats). One nice addition is that geopandas integrates (and simplifies) fiona, a library for reading and writing a wide variety of geographical data formats. This makes reading and writing geographical data files very easy.

4 Mapping Geometry mapped with: You can also plot slices etc.
gdf.plot(); You can also plot slices etc. To make a choropleth, give a column other than geometry: gdf.plot(column='col1'); To plot datapoints, use a basemap plus points: base = gdf.plot(color='white', edgecolor='black') pts.plot(ax=base, marker='o', color='blue', markersize=2); Wraps round matplotlib, so there are other options: As with pandas, producing a map is often just a matter of calling "plot". This will show the geometry data by default. The above slide gives the basics of also showing additional data columns and layers.

5 Data processing Columns can be referred to by column names, where good variable names. Also attributes: area: in projection units bounds: tuple of per-shape max and min coordinates total_bounds: tuple of per-dataframe max and min coordinates gdf.col1 = gdf.col1 / gdf.geometry.area As with pandas, columns can be created as the results of equations containing other columns, working elementwise. There are also a number of pre-calculated attributes associated with geometries.

6 Other operations Overlay (union; intersection; symmetrical difference; difference) Reprojection Buffering, convex hulls, etc. Scaling, translations, etc. Grouping and dissolves, attribute and spatial merges Geocoding through geocoding services (e.g. Google) Feature-to-feature distances Centroid finding Intersection and feature-in-feature checking GeoPandas adds a range of additional functions, encompassing much of the work you'd associated with a basic GIS. The documentation is generally good, and can be found, with examples, at the URL above. The functions have a very Pythonic style, with ease-of-use being of high importance. In general, as numpy gets wrapped deeper and deeper inside packages, the packages get more restricted in the kinds of jobs they'll do, but the process of analysis and visualisation gets easier and easier.


Download ppt "Mapping packages Unfortunately none come with Anaconda (only geoprocessing is http://proj4.org/ which does lat/long to Cartesian conversions). matplotlib."

Similar presentations


Ads by Google