SlideShare a Scribd company logo
Reading and writing spatial data for the non-spatial programmer
                                                                                                          Chad Cooper
                                                                                           Center for Advanced Spatial Technologies
          For help, visit:                                                                    University of Arkansas, Fayetteville
                                                                                         http://cast.uark.edu | chad@cast.uark.edu



                                    The Problem                                                                                                              The Solutions
Location has become ubiquitous in today’s society and is integral in everything from web                            Fortunately, Python is tightly integrated, accepted, and used within the GIS community, and has been for
applications, to smartphone apps, to automotive navigation systems. Spatial data, often derived                     some time. Python packages and other libraries that are accessible through Python exist to both read and
from Geographic Information Systems (GIS), drives these applications at their core. More and                        write many common (and some not so common) spatial data formats. With the help of these packages
more, non-spatial developers and programmers with little or no knowledge of spatial data                            and libraries, Python developers can manipulate, read, and write many spatial data formats.
formats are being tasked with working with and consuming spatial data in their applications.
Spatial data exists in a wide variety of formats which often adds to the confusion and complexity.                                           (Some) Libraries for working with spatial data
We need to be able to make sense of the formats and read/write them with Python.
                                                                                                                                                 Translator library (C++)                    import ogr
                                                                                                                                                                                             driver = ogr.GetDriverByName(“ESRI Shapefile”)
                                                                                                                                                 GDAL – raster data
                    Spatial data formats (a [very] small sampling)                                                                GDAL/OGR       OGR – vector data
                                                                                                                                                                                             ds = driver.Open(“world.shp”)
                                                                                                                                                                                             layer = ds.GetLayer()
                                                                                                                                                                                             feat_count = layer.GetFeatureCount()
                                                                                                                                                 Python bindings available.         Open     extent = layer.GetExtent()
File-based                                                                                                                                       source.
                                                                                                                                                                                             >>> import shapefile
                                                                                                                                                                                             >>> sf = "Farms"
                             Vector storage of points, lines,                                                                                                                                >>> sfr = shapefile.Reader(sf)
                             polygons. Open specification.                                                                                       Pure Python library for reading and         >>> sfr.fields
                             Around since early 90's. Very                                                                        pyshp          writing Esri shapefiles. Compatible with    [['ID', 'C', 254, 0],
              Shapefile                                                                                                                          Python 2.4 to 3.x. Open source.             ['Lat', 'F', 19, 11],
                             common and widely used and                                                                                                                                      ['Lon', 'F', 19, 11],
                                                                                                                                                                                             ['Farm_Name', 'C', 254, 0]]
                             available. Made up of at least
                             3 files: .shp, .shx, .dbf                                                                                           Python package for programming with         >>>coords = [(0, 0), (1, 1)]
                                                                                                                                                 2D geospatial geometries. Perform           >>> LineString(coords).contains(Point(0.5, 0.5))
                                                                                                                                  shapely        PostGIS type geometry operations
                                                                                                                                                                                             True
                                                                                                                                                                                             >>> Point(0.5, 0.5).within(LineString(coords))
                                                                                                                                                 outside of an RDBMS. Open source.           True
                             Columns and rows of data.
                             Think elevation data or land
                                                                                                                                                                                             >>> import pyproj
              Raster         use where each cell stores a                                                                                        Performs cartographic transformations       >>> lat1, lon1 = (36.076040, -94.137640)
                             single value. Can be ASCII or                                                                                       and geodetic computations. Convert          >>> lat2, lon2 = (37.404473, -121.975150)
                                                                                                                                                                                             >>> geod = pyproj.Geod(ellps="WGS84")
                             binary (TIFF, JPEG, etc.).                                                                                          from lat/lon to x/y or between
                                                                                                                                  pyproj                                                     >>> angle1, angle2, distance = geod.inv(lon1,
                                                                                                                                                 projected coordinate systems. Perform       lat1, lon2, lat2)
                                                                                                                                                                                             >>> print "It's %0.0f miles to Chad's house from
                                                                                                                                                 Great Circle computations. Wraps            PyCon 2012." % (distance * 0.000621)
                                                                <kml xmlns:gx="http://www.google.com/kml/ext/
                             Keyhole Markup Language.           2.2" xmlns:atom="http://www.w3.org/2005/Atom"                                    PROJ.4 library.                             It's 1541 miles to Chad's house from PyCon 2012.
                                                                xmlns="http://www.opengis.net/kml/2.2">
                             XML notation. Can be used in         <Placemark>                                                                    C/C++ library for reading and writing the
   .kml                      Google Earth and Google                <name>PyCon 2012</name>                                                                                                  from liblas import file
   .kmz       KML                                                   <Point>                                                                      LAS LiDAR format. A building block for      f = file.File('file.las',mode='r')
                             Maps. Can be simple with just            <coordinates>-121.9751,37.4044,0</                          libLAS         developers looking to implement their       for p in f:
                             geographic data or complex         coordinates>
                                                                                                                                                 own LiDAR data processing. Open
                                                                                                                                                                                                 print 'X,Y,Z: ', p.x, p.y, p.z
                                                                    </Point>
                             with styling. Vector or raster.      </Placemark>                                                                   source. Python API.
                                                                </kml>                                                                                                                       from pysqlite2 import dbapi2 as sqlite
                                                                                                                                                                                             conn = sqlite.connect('test.db')

                             Light Detection and Ranging.                                                                                        Python binding for the SQLite database      conn.enable_load_extension(True)
                                                                                                                                  PySqLite                                                   conn.execute(‘SELECT load_extension(
                             Distance to object measured                                                                                         engine.                                                  “libspatialite.dll”)’)
   .las                                                                                                                                                                                      cursor = conn.cursor()
   .laz       LiDAR          by illuminating target with
                             light, often from a laser. Point                                                                                                                                from lxml import etree
                                                                                                                                                                                             from pykml.factory import KML_ElementMaker as KML
                             clouds, elevation data.                                                                                                                                         doc = KML.kml(KML.Placemark(
                                                                                                                                                 Python package for creating, parsing,               KML.name('PyCon 2012'),
                                                                                                                                                                                                     KML.Point(
                                                                                                                                  pyKML          manipulating, and validating KML. Open                 KML.coordinates('-121.9751,37.4044,0'),
                                                                                                                                                 source.
Geodatabases                                                                                                                                                                                         ),),)
                                                                                                                                                                                             outfile = file(__file__.rstrip('.py')+'.kml','w')
                                                                                                                                                                                             outfile.write(etree.tostring(
                                                                                                                                                                                                           doc, pretty_print=True))
                             Spatially enables PostgreSQL.
              PostGIS        FOSS. Stores vector and raster                                                                                      Add-on for Django that turns it into a
                             data. Native Python support.                                                                         geodjango      geographic Web framework. Cross
                                                                                                                                                 platform.

                             Open source library that                                                                                            C++ open source toolkit for developing      import mapnik
                             extends SQLite to support                                                                                                                                       m = mapnik.Map(500, 500)
                                                                                                                                                 mapping applications. Python bindings.
              SpatiaLite     spatial capabilities. Stores
                                                                                                                                                                                             ...
                                                                                                                                  mapnik         For desktop and web development.            s = mapnik.Style()
                             vector and raster data.                                                                                                                                         ds = mapnik.Shapefile(file=”world.shp”)
                                                                                                                                                 Uses shapefile, PostGIS, GDAL/OGR           ...
                                                                                                                                                 datasources.                                mapnik.render_to_file(m, “world.png”, “png”)

                          Esri proprietary file-based
                          storage system. C++ API                                                                                                                                            import arcpy
                                                                                                                                                 Site package for performing geographic      import os
              File        recently released (could be                                                                                            data analysis, data conversion, data        fc_list = arcpy.ListFeatureClasses(gdb)
                                                                                                                                                                                             for in_fc in fc_list:
              Geodatabase wrapped with SWIG to use                                                                                arcpy          management, and map automation                  desc = arcpy.Describe(in_fc)
                          with Python). Stores vector                                                                                            with Python. Not open source.                   if desc.shapeType == 'Point':
                          and raster data.                                                                                                                                                           arcpy.Buffer_analysis(in_fc, out_fc,
                                                                                                                                                 Integrated with Esri ArcGIS suite.                                        3000)

More Related Content

Viewers also liked (6)

Introduction to spatial tech mac feb 2012
Introduction to spatial tech mac feb 2012Introduction to spatial tech mac feb 2012
Introduction to spatial tech mac feb 2012
daniellecart
 
Spatial datasets in support of decision making
Spatial datasets in support of decision makingSpatial datasets in support of decision making
Spatial datasets in support of decision making
Elsie Zwennis (Marketing)
 
Creating Powerful Geography: a toolkit
Creating Powerful Geography: a toolkitCreating Powerful Geography: a toolkit
Creating Powerful Geography: a toolkit
Karl Donert
 
Spatial Technology Resources for Teachers
Spatial Technology Resources for TeachersSpatial Technology Resources for Teachers
Spatial Technology Resources for Teachers
Rebecca Nicholas
 
Using Spatial Technologies in the Geography Classroom
Using Spatial Technologies in the Geography ClassroomUsing Spatial Technologies in the Geography Classroom
Using Spatial Technologies in the Geography Classroom
Rebecca Nicholas
 
S.H.E.E.P.T. Factors (Analysis)
S.H.E.E.P.T. Factors (Analysis)S.H.E.E.P.T. Factors (Analysis)
S.H.E.E.P.T. Factors (Analysis)
Yaryalitsa
 
Introduction to spatial tech mac feb 2012
Introduction to spatial tech mac feb 2012Introduction to spatial tech mac feb 2012
Introduction to spatial tech mac feb 2012
daniellecart
 
Spatial datasets in support of decision making
Spatial datasets in support of decision makingSpatial datasets in support of decision making
Spatial datasets in support of decision making
Elsie Zwennis (Marketing)
 
Creating Powerful Geography: a toolkit
Creating Powerful Geography: a toolkitCreating Powerful Geography: a toolkit
Creating Powerful Geography: a toolkit
Karl Donert
 
Spatial Technology Resources for Teachers
Spatial Technology Resources for TeachersSpatial Technology Resources for Teachers
Spatial Technology Resources for Teachers
Rebecca Nicholas
 
Using Spatial Technologies in the Geography Classroom
Using Spatial Technologies in the Geography ClassroomUsing Spatial Technologies in the Geography Classroom
Using Spatial Technologies in the Geography Classroom
Rebecca Nicholas
 
S.H.E.E.P.T. Factors (Analysis)
S.H.E.E.P.T. Factors (Analysis)S.H.E.E.P.T. Factors (Analysis)
S.H.E.E.P.T. Factors (Analysis)
Yaryalitsa
 

Similar to Reading and writing spatial data for the non-spatial programmer (20)

Pycon 2012 Taiwan
Pycon 2012 TaiwanPycon 2012 Taiwan
Pycon 2012 Taiwan
Dongpo Deng
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
pycontw
 
Advanced geoprocessing with Python
Advanced geoprocessing with PythonAdvanced geoprocessing with Python
Advanced geoprocessing with Python
Chad Cooper
 
Arc gis desktop_and_geoprocessing
Arc gis desktop_and_geoprocessingArc gis desktop_and_geoprocessing
Arc gis desktop_and_geoprocessing
Esri
 
Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGIS
Xander Bakker
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial data
Kudos S.A.S
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
Ilya Rosenfeld
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjango
Calvin Cheng
 
Python in geospatial analysis
Python in geospatial analysisPython in geospatial analysis
Python in geospatial analysis
Sakthivel R
 
Esri International User Conference 2011: Python: Integrating Standard and Thi...
Esri International User Conference 2011: Python: Integrating Standard and Thi...Esri International User Conference 2011: Python: Integrating Standard and Thi...
Esri International User Conference 2011: Python: Integrating Standard and Thi...
jasonscheirer
 
Foss4g it-2011 (english)
Foss4g it-2011 (english)Foss4g it-2011 (english)
Foss4g it-2011 (english)
GeoSolutions
 
GeoServer @ Osgis 2011
GeoServer @ Osgis 2011 GeoServer @ Osgis 2011
GeoServer @ Osgis 2011
GeoSolutions
 
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT RasterLe projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
ACSG Section Montréal
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCE
AhasanHabibSajeeb
 
Analysing GeoServer compatibility with INSPIRE requirements
Analysing GeoServer compatibility  with INSPIRE requirements Analysing GeoServer compatibility  with INSPIRE requirements
Analysing GeoServer compatibility with INSPIRE requirements
GeoSolutions
 
Digital mapping
Digital mappingDigital mapping
Digital mapping
Julian Swindell
 
Hengl & Reuter poster at Geomorphometry.org/2011
Hengl & Reuter poster at Geomorphometry.org/2011Hengl & Reuter poster at Geomorphometry.org/2011
Hengl & Reuter poster at Geomorphometry.org/2011
Tomislav Hengl
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
OSCON Byrum
 
PyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and MapsPyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and Maps
Hannes Hapke
 
Pycon 2012 Taiwan
Pycon 2012 TaiwanPycon 2012 Taiwan
Pycon 2012 Taiwan
Dongpo Deng
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
pycontw
 
Advanced geoprocessing with Python
Advanced geoprocessing with PythonAdvanced geoprocessing with Python
Advanced geoprocessing with Python
Chad Cooper
 
Arc gis desktop_and_geoprocessing
Arc gis desktop_and_geoprocessingArc gis desktop_and_geoprocessing
Arc gis desktop_and_geoprocessing
Esri
 
Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGIS
Xander Bakker
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial data
Kudos S.A.S
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
Ilya Rosenfeld
 
Saving Gaia with GeoDjango
Saving Gaia with GeoDjangoSaving Gaia with GeoDjango
Saving Gaia with GeoDjango
Calvin Cheng
 
Python in geospatial analysis
Python in geospatial analysisPython in geospatial analysis
Python in geospatial analysis
Sakthivel R
 
Esri International User Conference 2011: Python: Integrating Standard and Thi...
Esri International User Conference 2011: Python: Integrating Standard and Thi...Esri International User Conference 2011: Python: Integrating Standard and Thi...
Esri International User Conference 2011: Python: Integrating Standard and Thi...
jasonscheirer
 
Foss4g it-2011 (english)
Foss4g it-2011 (english)Foss4g it-2011 (english)
Foss4g it-2011 (english)
GeoSolutions
 
GeoServer @ Osgis 2011
GeoServer @ Osgis 2011 GeoServer @ Osgis 2011
GeoServer @ Osgis 2011
GeoSolutions
 
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT RasterLe projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster
ACSG Section Montréal
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCE
AhasanHabibSajeeb
 
Analysing GeoServer compatibility with INSPIRE requirements
Analysing GeoServer compatibility  with INSPIRE requirements Analysing GeoServer compatibility  with INSPIRE requirements
Analysing GeoServer compatibility with INSPIRE requirements
GeoSolutions
 
Hengl & Reuter poster at Geomorphometry.org/2011
Hengl & Reuter poster at Geomorphometry.org/2011Hengl & Reuter poster at Geomorphometry.org/2011
Hengl & Reuter poster at Geomorphometry.org/2011
Tomislav Hengl
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And PythonwinPython And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
OSCON Byrum
 
PyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and MapsPyDX Presentation about Python, GeoData and Maps
PyDX Presentation about Python, GeoData and Maps
Hannes Hapke
 

Recently uploaded (20)

Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025
Splunk
 
AI against disinformation and why it is not enough
AI against disinformation and why it is not enoughAI against disinformation and why it is not enough
AI against disinformation and why it is not enough
Yiannis Kompatsiaris
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AIAI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
Buhake Sindi
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptxFrom Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
Mohammad Jomaa
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4
Razin Mustafiz
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 
Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025
Splunk
 
AI against disinformation and why it is not enough
AI against disinformation and why it is not enoughAI against disinformation and why it is not enough
AI against disinformation and why it is not enough
Yiannis Kompatsiaris
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AIAI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
Buhake Sindi
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptxFrom Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
Mohammad Jomaa
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4
Razin Mustafiz
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 

Reading and writing spatial data for the non-spatial programmer

  • 1. Reading and writing spatial data for the non-spatial programmer Chad Cooper Center for Advanced Spatial Technologies For help, visit: University of Arkansas, Fayetteville http://cast.uark.edu | [email protected] The Problem The Solutions Location has become ubiquitous in today’s society and is integral in everything from web Fortunately, Python is tightly integrated, accepted, and used within the GIS community, and has been for applications, to smartphone apps, to automotive navigation systems. Spatial data, often derived some time. Python packages and other libraries that are accessible through Python exist to both read and from Geographic Information Systems (GIS), drives these applications at their core. More and write many common (and some not so common) spatial data formats. With the help of these packages more, non-spatial developers and programmers with little or no knowledge of spatial data and libraries, Python developers can manipulate, read, and write many spatial data formats. formats are being tasked with working with and consuming spatial data in their applications. Spatial data exists in a wide variety of formats which often adds to the confusion and complexity. (Some) Libraries for working with spatial data We need to be able to make sense of the formats and read/write them with Python. Translator library (C++) import ogr driver = ogr.GetDriverByName(“ESRI Shapefile”) GDAL – raster data Spatial data formats (a [very] small sampling) GDAL/OGR OGR – vector data ds = driver.Open(“world.shp”) layer = ds.GetLayer() feat_count = layer.GetFeatureCount() Python bindings available. Open extent = layer.GetExtent() File-based source. >>> import shapefile >>> sf = "Farms" Vector storage of points, lines, >>> sfr = shapefile.Reader(sf) polygons. Open specification. Pure Python library for reading and >>> sfr.fields Around since early 90's. Very pyshp writing Esri shapefiles. Compatible with [['ID', 'C', 254, 0], Shapefile Python 2.4 to 3.x. Open source. ['Lat', 'F', 19, 11], common and widely used and ['Lon', 'F', 19, 11], ['Farm_Name', 'C', 254, 0]] available. Made up of at least 3 files: .shp, .shx, .dbf Python package for programming with >>>coords = [(0, 0), (1, 1)] 2D geospatial geometries. Perform >>> LineString(coords).contains(Point(0.5, 0.5)) shapely PostGIS type geometry operations True >>> Point(0.5, 0.5).within(LineString(coords)) outside of an RDBMS. Open source. True Columns and rows of data. Think elevation data or land >>> import pyproj Raster use where each cell stores a Performs cartographic transformations >>> lat1, lon1 = (36.076040, -94.137640) single value. Can be ASCII or and geodetic computations. Convert >>> lat2, lon2 = (37.404473, -121.975150) >>> geod = pyproj.Geod(ellps="WGS84") binary (TIFF, JPEG, etc.). from lat/lon to x/y or between pyproj >>> angle1, angle2, distance = geod.inv(lon1, projected coordinate systems. Perform lat1, lon2, lat2) >>> print "It's %0.0f miles to Chad's house from Great Circle computations. Wraps PyCon 2012." % (distance * 0.000621) <kml xmlns:gx="http://www.google.com/kml/ext/ Keyhole Markup Language. 2.2" xmlns:atom="http://www.w3.org/2005/Atom" PROJ.4 library. It's 1541 miles to Chad's house from PyCon 2012. xmlns="http://www.opengis.net/kml/2.2"> XML notation. Can be used in <Placemark> C/C++ library for reading and writing the .kml Google Earth and Google <name>PyCon 2012</name> from liblas import file .kmz KML <Point> LAS LiDAR format. A building block for f = file.File('file.las',mode='r') Maps. Can be simple with just <coordinates>-121.9751,37.4044,0</ libLAS developers looking to implement their for p in f: geographic data or complex coordinates> own LiDAR data processing. Open print 'X,Y,Z: ', p.x, p.y, p.z </Point> with styling. Vector or raster. </Placemark> source. Python API. </kml> from pysqlite2 import dbapi2 as sqlite conn = sqlite.connect('test.db') Light Detection and Ranging. Python binding for the SQLite database conn.enable_load_extension(True) PySqLite conn.execute(‘SELECT load_extension( Distance to object measured engine. “libspatialite.dll”)’) .las cursor = conn.cursor() .laz LiDAR by illuminating target with light, often from a laser. Point from lxml import etree from pykml.factory import KML_ElementMaker as KML clouds, elevation data. doc = KML.kml(KML.Placemark( Python package for creating, parsing, KML.name('PyCon 2012'), KML.Point( pyKML manipulating, and validating KML. Open KML.coordinates('-121.9751,37.4044,0'), source. Geodatabases ),),) outfile = file(__file__.rstrip('.py')+'.kml','w') outfile.write(etree.tostring( doc, pretty_print=True)) Spatially enables PostgreSQL. PostGIS FOSS. Stores vector and raster Add-on for Django that turns it into a data. Native Python support. geodjango geographic Web framework. Cross platform. Open source library that C++ open source toolkit for developing import mapnik extends SQLite to support m = mapnik.Map(500, 500) mapping applications. Python bindings. SpatiaLite spatial capabilities. Stores ... mapnik For desktop and web development. s = mapnik.Style() vector and raster data. ds = mapnik.Shapefile(file=”world.shp”) Uses shapefile, PostGIS, GDAL/OGR ... datasources. mapnik.render_to_file(m, “world.png”, “png”) Esri proprietary file-based storage system. C++ API import arcpy Site package for performing geographic import os File recently released (could be data analysis, data conversion, data fc_list = arcpy.ListFeatureClasses(gdb) for in_fc in fc_list: Geodatabase wrapped with SWIG to use arcpy management, and map automation desc = arcpy.Describe(in_fc) with Python). Stores vector with Python. Not open source. if desc.shapeType == 'Point': and raster data. arcpy.Buffer_analysis(in_fc, out_fc, Integrated with Esri ArcGIS suite. 3000)