SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
那些年Python攻佔GIS
                         The Year Python Takes Over GIS



                                鄧東波 Dongpo Deng
                               中央研究院資訊科學研究所
                                      ﹠
                              胡崇偉 marr, Tsung Wei Hu
                              中央研究院人文社會科學中心
                                    PyCon 2012

Saturday, June 9, 2012
Content

                     • Introduction - GIS and why GIS uses
                         python
                     • Python-blinding core geospatial libraries
                     • the use of python in Desktop GISs
                     • Web application framework for geospatial

Saturday, June 9, 2012
What is GIS?
             •      GIS is stand for Geographic
                    Information System
                   •     integrates hardware, software,
                         and data for capturing,
                         managing, analyzing, and
                         displaying geospatial data.
                   •     allows people to use methods
                         for understanding,
                         interpreting, and visualizing
                         relationships and patterns of
                         geospatial data
Saturday, June 9, 2012
Why Geospatial domain uses Python

                     •   Easy to learn
                     •   Code is readable
                     •   Large community
                     •   Easy interaction with C and Java libraries
                     •   Many existing modules and packages
                         •   core geospatial libraries
                         •   map rendering
                         •   database
                         •   web server

                                                                      Picture from http://pypi.python.org/pypi/collective.geo.bundle

Saturday, June 9, 2012
Why Geospatial domain uses Python

                     •   Easy to learn
                     •   Code is readable
                     •   Large community
                     •   Easy interaction with C and Java libraries
                     •   Many existing modules and packages
                         •   core geospatial libraries
                         •   map rendering
                         •   database
                         •   web server

                                                                      Picture from http://pypi.python.org/pypi/collective.geo.bundle

Saturday, June 9, 2012
Geospatial development tasks
                     • Visualizing geospatial data




Saturday, June 9, 2012
Geospatial development tasks
                 • Analyzing geospatial data
                   • e.g. How many people should escape as
                           Kuosheng nuclear power plant (核二廠)
                           explodes?
                     •   Create a geospatial mashup




Saturday, June 9, 2012
The geospatial development tasks
                                involve
           •       Math- analytic geometry
                 •       e.g.Euclidean geometry
           •       Computer graphics (rendering)
                 •       e.g. rending, visualizing
           •       Database
                 •       General Search Tree (GiST)
                 •       open geospatial standards,
                 •       e.g. GML, WKT

Saturday, June 9, 2012
Python libraries for geospatial
                                 development
                     •   Reading/ Writing geospatial data
                         •   GDAL/OGR
                     •   Dealing with Projections
                         •   pyproj
                     •   Analyzing and manipulating geospatial data
                         •   Shapely
                     •   Visualizing geospatial data
                         •   Mapnik

Saturday, June 9, 2012
GDAL
               (Geospatial Data Abstraction Library)
                                                              •   read through it one scanline at a time
  from osgeo import gdal,gdalconst                                from file
  import struct
  dataset = gdal.Open("DEM.dat")                              •   use the struct standard Python library
  band = dataset.GetRasterBand(1)                                 module to read the individual values out
  fmt = "<" + ("h" * band.XSize)                                  of the scanline.
  totHeight = 0
  for y in range(band.YSize):                                 •   Each value corresponds to the height of
     scanline = band.ReadRaster(0, y,                             that point, in meters
  band.XSize, 1, band.XSize,
  1,band.DataType)
     values = struct.unpack(fmt,
  scanline)
     for value in values:
        totHeight = totHeight + value
  average = totHeight / (band.XSize *
  band.YSize)
  print "Average height =", average

   Source from: Westra, 2010, Python Geospatial Development
Saturday, June 9, 2012
OGR
                  (OpenGIS Simple Features Reference Implementation)


            •       uses OGR to read through the contents of a Shapefile,
            •       printing out the value of the NAME attribute for each
                    feature, along with the geometry type

  from osgeo import ogr
  shapefile = ogr.Open("TM_WORLD.shp")
  layer = shapefile.GetLayer(0)
  for i in range(layer.GetFeatureCount()):
       feature = layer.GetFeature(i)
       name = feature.GetField("NAME")
       geometry = feature.GetGeometryRef()
       print i, name, geometry.GetGeometryName()



   Source from: Westra, 2010, Python Geospatial Development
Saturday, June 9, 2012
PyProj
                     •   a location specified using UTM zone 17 coordinates.
                     •   Using two Proj objects to define the UTM Zone 17 and
                         lat/long projections
                     •   translates this location's coordinates into latitude and
                         longitude values
    import pyproj
    UTM_X = 565718.523517
    UTM_Y = 3980998.9244
    srcProj = pyproj.Proj(proj="utm", zone="11",
    ellps="clrk66", units="m")
    dstProj = pyproj.Proj(proj='longlat', ellps='WGS84',
    datum='WGS84')
    long,lat = pyproj.transform(srcProj, dstProj, UTM_X, UTM_Y)
    print "UTM zone 17 coordinate (%0.4f, %0.4f) = %0.4f, %0.4f" %
    (UTM_X, UTM_Y, lat, long)
                                                           Source from: Westra, 2010, Python Geospatial Development
Saturday, June 9, 2012
Shapely GEOS
 import shapely.geometry
 pt = shapely.geometry.Point(0, 0)
 circle = pt.buffer(1.0)
 square = shapely.geometry.Polygon([(0, 0),
                                        (1, 0),
                                        (1, 1),
                                        (0, 1),
                                        (0, 0)])
 intersect = circle.intersection(square)
 for x,y in intersect.exterior.coords:
    print x,y




                                                   Source from: Westra, 2010, Python Geospatial Development
Saturday, June 9, 2012
Mapnik

      •      Mapnik is an open source mapping
             toolkit for desktop- and server-based
             map rendering, written in C++.
      •      there are Python bindings to facilitate
             fast-paced agile development.
      •      OpenStreetMap project (OSM) uses
             Mapnik in combination with an
             Apache Web Server module
             (mod_tile) to render tiles that make
             up the OSM 'Slippy Map' Layer.

                                                Source from: Westra, 2010, Python Geospatial Development

Saturday, June 9, 2012
Mapnik
  import mapnik
  symbolizer = mapnik.PolygonSymbolizer(
  mapnik.Color("darkgreen"))
  rule = mapnik.Rule()
  rule.symbols.append(symbolizer)
  style = mapnik.Style()
  style.rules.append(rule)
  layer = mapnik.Layer("mapLayer")
  layer.datasource = mapnik.Shapefile(
  file="TW_village.shp")
  layer.styles.append("mapStyle")
  map = mapnik.Map(800, 400)
  map.background = mapnik.Color("steelblue")
  map.append_style("mapStyle", style)
  map.layers.append(layer)
  map.zoom_all()
  mapnik.render_to_file(map, "map.png", "png")
Saturday, June 9, 2012
Desktop GIS




                                  Pic from http://www.pressebox.de/attachments/details/39739

Saturday, June 9, 2012
Script Languages in ESRI family




Saturday, June 9, 2012
ArcPy
                     •   ArcPy is a package for performing geographic data
                         analysis, data conversion, data management, and
                         map automation in ArcGIS with Python.
                     •   ArcPy includes three modules:
                         •   mapping module (arcpy.mapping)
                         •   Spatial analyst module (arcpy.sa)
                         •   Geostatistical analyst module (arcpy.ga)



                                    ArcGIS ArcPy     Python


                                                    http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_ArcPy/
Saturday, June 9, 2012
arcpy in ArcGIS 10




Saturday, June 9, 2012
Saturday, June 9, 2012
Saturday, June 9, 2012
Python in QGIS
                     •   There’s a number of ways to access the layers in
                         QGIS.
                     •   Each way starts by first referencing the
                         QgisInterface class which is called iface in the
                         Python bindings.




Saturday, June 9, 2012
Example




Saturday, June 9, 2012
GeoDjango




Saturday, June 9, 2012
http://140.109.160.129:8000/admin/world/worldborders/
Saturday, June 9, 2012
Remarks

                     • There are many Python libraries or
                         applications for geospatial purposes
                     • Python is increasing its value in geospatial
                         domain
                     • Will Python take over GIS? .....Let’s see!

Saturday, June 9, 2012
Thank you for attention!


                            dongpo.deng@gmail.com
                              marr.tw@gmail.com




Saturday, June 9, 2012

Más contenido relacionado

Similar a 那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS

Pg intro part1-theory_slides
Pg intro part1-theory_slidesPg intro part1-theory_slides
Pg intro part1-theory_slideslasmasi
 
Building Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART IBuilding Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART Ilasmasi
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial dataKudos S.A.S
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
OpenStreetMap in 3D - current developments
OpenStreetMap in 3D - current developmentsOpenStreetMap in 3D - current developments
OpenStreetMap in 3D - current developmentsvirtualcitySYSTEMS GmbH
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCEAhasanHabibSajeeb
 
Bring Satellite and Drone Imagery into your Data Science Workflows
Bring Satellite and Drone Imagery into your Data Science WorkflowsBring Satellite and Drone Imagery into your Data Science Workflows
Bring Satellite and Drone Imagery into your Data Science WorkflowsDatabricks
 
The State of Big Data for Geo - ESRI Big Data Meetup
The State of Big Data for Geo - ESRI Big Data MeetupThe State of Big Data for Geo - ESRI Big Data Meetup
The State of Big Data for Geo - ESRI Big Data Meetupseagor
 
FOSS4G 2017 - Geonotebook: an extension to the jupyter notebook for explora...
FOSS4G 2017 - Geonotebook:   an extension to the jupyter notebook for explora...FOSS4G 2017 - Geonotebook:   an extension to the jupyter notebook for explora...
FOSS4G 2017 - Geonotebook: an extension to the jupyter notebook for explora...Christopher Kotfila
 
Analysis Ready Data workshop - OGC presentation
Analysis Ready Data workshop - OGC presentation Analysis Ready Data workshop - OGC presentation
Analysis Ready Data workshop - OGC presentation George Percivall
 
GeoDataspace: Simplifying Data Management Tasks with Globus
GeoDataspace: Simplifying Data Management Tasks with GlobusGeoDataspace: Simplifying Data Management Tasks with Globus
GeoDataspace: Simplifying Data Management Tasks with GlobusTanu Malik
 
Powerful geographic web framework GeoDjango
Powerful geographic web framework GeoDjangoPowerful geographic web framework GeoDjango
Powerful geographic web framework GeoDjangoOMEGA (@equal_001)
 
Project Matsu: Elastic Clouds for Disaster Relief
Project Matsu: Elastic Clouds for Disaster ReliefProject Matsu: Elastic Clouds for Disaster Relief
Project Matsu: Elastic Clouds for Disaster ReliefRobert Grossman
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GISbryanluman
 
Python in geoinformatics
Python in geoinformaticsPython in geoinformatics
Python in geoinformaticsMapWindow GIS
 
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...SoftwarePractice
 

Similar a 那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS (20)

Pg intro part1-theory_slides
Pg intro part1-theory_slidesPg intro part1-theory_slides
Pg intro part1-theory_slides
 
Building Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART IBuilding Location Aware Apps - Get Started with PostGIS, PART I
Building Location Aware Apps - Get Started with PostGIS, PART I
 
Using python to analyze spatial data
Using python to analyze spatial dataUsing python to analyze spatial data
Using python to analyze spatial data
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
OpenStreetMap in 3D - current developments
OpenStreetMap in 3D - current developmentsOpenStreetMap in 3D - current developments
OpenStreetMap in 3D - current developments
 
APPLICATION OF PYTHON IN GEOSCIENCE
APPLICATION OF  PYTHON IN GEOSCIENCEAPPLICATION OF  PYTHON IN GEOSCIENCE
APPLICATION OF PYTHON IN GEOSCIENCE
 
Bring Satellite and Drone Imagery into your Data Science Workflows
Bring Satellite and Drone Imagery into your Data Science WorkflowsBring Satellite and Drone Imagery into your Data Science Workflows
Bring Satellite and Drone Imagery into your Data Science Workflows
 
The State of Big Data for Geo - ESRI Big Data Meetup
The State of Big Data for Geo - ESRI Big Data MeetupThe State of Big Data for Geo - ESRI Big Data Meetup
The State of Big Data for Geo - ESRI Big Data Meetup
 
State of JTS 2018
State of JTS 2018State of JTS 2018
State of JTS 2018
 
FOSS4G 2017 - Geonotebook: an extension to the jupyter notebook for explora...
FOSS4G 2017 - Geonotebook:   an extension to the jupyter notebook for explora...FOSS4G 2017 - Geonotebook:   an extension to the jupyter notebook for explora...
FOSS4G 2017 - Geonotebook: an extension to the jupyter notebook for explora...
 
What in the World
What in the WorldWhat in the World
What in the World
 
Analysis Ready Data workshop - OGC presentation
Analysis Ready Data workshop - OGC presentation Analysis Ready Data workshop - OGC presentation
Analysis Ready Data workshop - OGC presentation
 
GeoDataspace: Simplifying Data Management Tasks with Globus
GeoDataspace: Simplifying Data Management Tasks with GlobusGeoDataspace: Simplifying Data Management Tasks with Globus
GeoDataspace: Simplifying Data Management Tasks with Globus
 
Open@EDINA
Open@EDINAOpen@EDINA
Open@EDINA
 
Powerful geographic web framework GeoDjango
Powerful geographic web framework GeoDjangoPowerful geographic web framework GeoDjango
Powerful geographic web framework GeoDjango
 
Project Matsu: Elastic Clouds for Disaster Relief
Project Matsu: Elastic Clouds for Disaster ReliefProject Matsu: Elastic Clouds for Disaster Relief
Project Matsu: Elastic Clouds for Disaster Relief
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GIS
 
Python in geoinformatics
Python in geoinformaticsPython in geoinformatics
Python in geoinformatics
 
No(Geo)SQL
No(Geo)SQLNo(Geo)SQL
No(Geo)SQL
 
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...
Adoption of Software By A User Community: The Montage Image Mosaic Engine Exa...
 

Más de pycontw

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Pythonpycontw
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSDpycontw
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法pycontw
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Pythonpycontw
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Pythonpycontw
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azurepycontw
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySidepycontw
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)pycontw
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Managementpycontw
 
Small Python Tools for Software Release Engineering
Small Python Tools for Software Release EngineeringSmall Python Tools for Software Release Engineering
Small Python Tools for Software Release Engineeringpycontw
 
Python and Startup
Python and StartupPython and Startup
Python and Startuppycontw
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...pycontw
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPypycontw
 
Python and the Web
Python and the WebPython and the Web
Python and the Webpycontw
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Pythonpycontw
 

Más de pycontw (15)

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Python
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSD
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Python
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azure
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySide
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Management
 
Small Python Tools for Software Release Engineering
Small Python Tools for Software Release EngineeringSmall Python Tools for Software Release Engineering
Small Python Tools for Software Release Engineering
 
Python and Startup
Python and StartupPython and Startup
Python and Startup
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPy
 
Python and the Web
Python and the WebPython and the Web
Python and the Web
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Python
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS

  • 1. 那些年Python攻佔GIS The Year Python Takes Over GIS 鄧東波 Dongpo Deng 中央研究院資訊科學研究所 ﹠ 胡崇偉 marr, Tsung Wei Hu 中央研究院人文社會科學中心 PyCon 2012 Saturday, June 9, 2012
  • 2. Content • Introduction - GIS and why GIS uses python • Python-blinding core geospatial libraries • the use of python in Desktop GISs • Web application framework for geospatial Saturday, June 9, 2012
  • 3. What is GIS? • GIS is stand for Geographic Information System • integrates hardware, software, and data for capturing, managing, analyzing, and displaying geospatial data. • allows people to use methods for understanding, interpreting, and visualizing relationships and patterns of geospatial data Saturday, June 9, 2012
  • 4. Why Geospatial domain uses Python • Easy to learn • Code is readable • Large community • Easy interaction with C and Java libraries • Many existing modules and packages • core geospatial libraries • map rendering • database • web server Picture from http://pypi.python.org/pypi/collective.geo.bundle Saturday, June 9, 2012
  • 5. Why Geospatial domain uses Python • Easy to learn • Code is readable • Large community • Easy interaction with C and Java libraries • Many existing modules and packages • core geospatial libraries • map rendering • database • web server Picture from http://pypi.python.org/pypi/collective.geo.bundle Saturday, June 9, 2012
  • 6. Geospatial development tasks • Visualizing geospatial data Saturday, June 9, 2012
  • 7. Geospatial development tasks • Analyzing geospatial data • e.g. How many people should escape as Kuosheng nuclear power plant (核二廠) explodes? • Create a geospatial mashup Saturday, June 9, 2012
  • 8. The geospatial development tasks involve • Math- analytic geometry • e.g.Euclidean geometry • Computer graphics (rendering) • e.g. rending, visualizing • Database • General Search Tree (GiST) • open geospatial standards, • e.g. GML, WKT Saturday, June 9, 2012
  • 9. Python libraries for geospatial development • Reading/ Writing geospatial data • GDAL/OGR • Dealing with Projections • pyproj • Analyzing and manipulating geospatial data • Shapely • Visualizing geospatial data • Mapnik Saturday, June 9, 2012
  • 10. GDAL (Geospatial Data Abstraction Library) • read through it one scanline at a time from osgeo import gdal,gdalconst from file import struct dataset = gdal.Open("DEM.dat") • use the struct standard Python library band = dataset.GetRasterBand(1) module to read the individual values out fmt = "<" + ("h" * band.XSize) of the scanline. totHeight = 0 for y in range(band.YSize): • Each value corresponds to the height of scanline = band.ReadRaster(0, y, that point, in meters band.XSize, 1, band.XSize, 1,band.DataType) values = struct.unpack(fmt, scanline) for value in values: totHeight = totHeight + value average = totHeight / (band.XSize * band.YSize) print "Average height =", average Source from: Westra, 2010, Python Geospatial Development Saturday, June 9, 2012
  • 11. OGR (OpenGIS Simple Features Reference Implementation) • uses OGR to read through the contents of a Shapefile, • printing out the value of the NAME attribute for each feature, along with the geometry type from osgeo import ogr shapefile = ogr.Open("TM_WORLD.shp") layer = shapefile.GetLayer(0) for i in range(layer.GetFeatureCount()): feature = layer.GetFeature(i) name = feature.GetField("NAME") geometry = feature.GetGeometryRef() print i, name, geometry.GetGeometryName() Source from: Westra, 2010, Python Geospatial Development Saturday, June 9, 2012
  • 12. PyProj • a location specified using UTM zone 17 coordinates. • Using two Proj objects to define the UTM Zone 17 and lat/long projections • translates this location's coordinates into latitude and longitude values import pyproj UTM_X = 565718.523517 UTM_Y = 3980998.9244 srcProj = pyproj.Proj(proj="utm", zone="11", ellps="clrk66", units="m") dstProj = pyproj.Proj(proj='longlat', ellps='WGS84', datum='WGS84') long,lat = pyproj.transform(srcProj, dstProj, UTM_X, UTM_Y) print "UTM zone 17 coordinate (%0.4f, %0.4f) = %0.4f, %0.4f" % (UTM_X, UTM_Y, lat, long) Source from: Westra, 2010, Python Geospatial Development Saturday, June 9, 2012
  • 13. Shapely GEOS import shapely.geometry pt = shapely.geometry.Point(0, 0) circle = pt.buffer(1.0) square = shapely.geometry.Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]) intersect = circle.intersection(square) for x,y in intersect.exterior.coords: print x,y Source from: Westra, 2010, Python Geospatial Development Saturday, June 9, 2012
  • 14. Mapnik • Mapnik is an open source mapping toolkit for desktop- and server-based map rendering, written in C++. • there are Python bindings to facilitate fast-paced agile development. • OpenStreetMap project (OSM) uses Mapnik in combination with an Apache Web Server module (mod_tile) to render tiles that make up the OSM 'Slippy Map' Layer. Source from: Westra, 2010, Python Geospatial Development Saturday, June 9, 2012
  • 15. Mapnik import mapnik symbolizer = mapnik.PolygonSymbolizer( mapnik.Color("darkgreen")) rule = mapnik.Rule() rule.symbols.append(symbolizer) style = mapnik.Style() style.rules.append(rule) layer = mapnik.Layer("mapLayer") layer.datasource = mapnik.Shapefile( file="TW_village.shp") layer.styles.append("mapStyle") map = mapnik.Map(800, 400) map.background = mapnik.Color("steelblue") map.append_style("mapStyle", style) map.layers.append(layer) map.zoom_all() mapnik.render_to_file(map, "map.png", "png") Saturday, June 9, 2012
  • 16. Desktop GIS Pic from http://www.pressebox.de/attachments/details/39739 Saturday, June 9, 2012
  • 17. Script Languages in ESRI family Saturday, June 9, 2012
  • 18. ArcPy • ArcPy is a package for performing geographic data analysis, data conversion, data management, and map automation in ArcGIS with Python. • ArcPy includes three modules: • mapping module (arcpy.mapping) • Spatial analyst module (arcpy.sa) • Geostatistical analyst module (arcpy.ga) ArcGIS ArcPy Python http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_ArcPy/ Saturday, June 9, 2012
  • 19. arcpy in ArcGIS 10 Saturday, June 9, 2012
  • 22. Python in QGIS • There’s a number of ways to access the layers in QGIS. • Each way starts by first referencing the QgisInterface class which is called iface in the Python bindings. Saturday, June 9, 2012
  • 26. Remarks • There are many Python libraries or applications for geospatial purposes • Python is increasing its value in geospatial domain • Will Python take over GIS? .....Let’s see! Saturday, June 9, 2012
  • 27. Thank you for attention! dongpo.deng@gmail.com marr.tw@gmail.com Saturday, June 9, 2012