
Geospatial Python Libraries and Tools for GIS Development
Explore a comprehensive collection of geospatial Python libraries and tools for GIS development, including PyCon 2012, Python, GDAL/OGR, Shapely, NumPy, Pandas, pyKML, and ArcPy. Learn about open-source programming, data analysis, and geographic data manipulation with these powerful resources.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
GIS and Python CAMERON GOODALE PAUL RAMIREZ
PyCon 2012 https://us.pycon.org/2012/ March 7th-11thin Santa Clara, CA Largest gathering of Python Developers (well over 2000) Lots of big name sponsors and plenty of job offerings Supported ESDSWG Software Reuse WG To learn about and proliferate open source and GIS
Python http://www.python.org/ Open source programming language Freely usable and distributable, even for commercial use Runs on Window, Linux/Unix, Mac OS X, and has been ported to Java and .NET virtual machines Use version 2.7 over 3.x for now as there are still some libraries that have yet to be ported
GDAL/OGR Geospatial Data Abstraction Library X/MIT style Open Source License http://www.gdal.org Manipulation of Raster Data Supported Formats http://www.gdal.org/formats_list.html OGR ships in GDAL source tree Manipulation of Vector data Python bindings available Plays well with NumPy GIS Swiss Army Knife
Shapely http://toblerity.github.com/shapely/ BSD Licensed Geometric objects, predicates, and operations outside the context of a database Manipulation and analysis of planar geometric objects Based on GEOS (i.e. the PostGIS engine) Interoperation with Well Known Text (WKT) Well Known Binary (WKB) Numpy and Python Arrays Any object that provides GeoJSON-like Python geo interface
NumPy http://numpy.scipy.org/ C/C++/Fortran Linear Algebra, N-dimensional arrays BSD License PyNGL and PyNIO From NCAR License on Earth System Grid site.
Pandas http://pandas.pydata.org/ Data Analysis New BSD License Great Video from a PyCon Tutorial http://blog.lambdafoundry.com/tutorial-data-analysis-in- python-with-pandas-at-pycon-2012/
pyKML Python library for creating, parsing, manipulating, and validating KML BSD License http://packages.python.org/pykml/
ArcPy http://help.arcgis.com/en/arcgisdesktop/10.0/help/ index.html#/What_is_ArcPy/000v000000v70000 00/ ESRI Python Library License ? ArcGIS scripting to do geographic data analysis, data conversion, data management, and map automation Access to geoprocessing tools Integrated with ESRI ArcGIS Suite
Mapnik http://mapnik.org/ Toolkit for Developing Mapping Apps Written in C++ Can be used with XML, Python, and node.js Runs on Linux, OS X, Windows License LGPL
TileStache http://tilestache.org/ Python-based Tile Server Simpler version of Tilecache (http://tilecache.org/) Runs on Linux, OS X, Windows License BSD
GeoDjango http://geodjango.org/ GIS for Django Supports Multiple Databases PostgreSQL + PostGIS Oracle Spatial Spatialite MySQL (least functional) License BSD
Leaflet http://leaflet.cloudmade.com/ Mapping component to support vector and image data Still early in development but very usable Replacement for Google Maps Many people moving away due to Google s recent changes Similar to OpenLayers but more compact and modern
QGIS http://www.qgis.org/ GPL License Desktop Software akin ArcGIS for Desktop Can be extended through plugins Several ways to interact with Python http://qgis.org/pyqgis-cookbook/intro.html Integrated Python Console Write a Python Plugin Write a python application to automate some process or create a GUI to measure data, export a map to PDF, etc.
Contact Us Cameron Goodale cgoodale@jpl.nasa.gov @sigep311 Paul Ramirez pramirez@jpl.nasa.gov @pramirez624
GDAL Example >>> import gdal >>> from gdalconst import * >>> dataset = gdal.Open( MOD09GA.A2012081.h23v08.005.2012083065418.hdf ) >>> dataset.GetMetadata('SUBDATASETS') >>> state_1km = gdal.Open(dataset.GetMetadata('SUBDATASETS')['SUBDATASET_2_NAME']) >>> state_1km.GetProjection() 'PROJCS["unnamed",GEOGCS["Unknown datum based upon the custom spheroid",DATUM["Not specified (based on custom spheroid)",SPHEROID["Custom spheroid",6371007.181,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],P ROJECTION["Sinusoidal"],PARAMETER["longitude_of_center",0],PARAMETER["false_easti ng",0],PARAMETER["false_northing",0],UNIT["Meter",1]] >>> layer = state_1km.ReadAsArray() >>> type(layer) <type 'numpy.ndarray'> >>> layer.shape (1200, 1200) >>> state_1km = None >>> dataset = None
OGR Example >>> import ogr >>> datasource = driver.Open( sites.shp') >>> layer = datasource.GetLayer() >>> feature = layer.GetNextFeature() >>> while feature: ... cover = feature.GetFieldAsString('cover') ... geom = feature.GetGeometryRef() ... print "x: %s y: %s" % (geom.GetX(), geom.GetY()) ... feature.Destroy() ... feature = layer.GetNextFeature() ... x: 455552.418361 y: 4641822.05368 x: 449959.840851 y: 4633802.50858 >>> datasource.Destroy()
Shapely Example >>> from shapely.geometry import Point, LineString, LinearRing, Polygon >>> Point(0,0).distance(Point(1,1)) 1.4142135623730951 >>> donut = Point(0, 0).buffer(2.0).difference(Point(0, 0).buffer(1.0)) >>> donut.area 9.409645471637816 >>> line = LineString([(0, 0), (1, 1)]) >>> line.length 1.4142135623730951 >>> line.coords[1:] [(1.0, 1.0)] >>> ring = LinearRing([(0, 0), (1, 1), (1, 0)]) >>> ring.length 3.414213562373095 >>> polygon = Polygon([(0, 0), (1, 1), (1, 0)]) >>> polygon.area 0.5 >>> LineString([(0, 0), (1, 1)]).contains(Point(0.5, 0.5)) True >>> Point(0.5, 0.5).within(LineString(coords)) True