SlideShare uma empresa Scribd logo
1 de 43
Baixar para ler offline
GIS, Python and company

    Igor Pochechuev
    22-23 October, 2011
    Kyiv, Ukraine
Content
●   What is geometry?
    geometry formats
●   How to store geo data?
    spatial databases
●   Where we can get geo data?
●   Render it!
●   Demo
General provisions
     what we got
Geometry
                       formats

●   WKT, WKB
●   KML, GML (xml based)
●   GeoJSON (json based)
●   Shapefile (ESRI open specification)
●   etc.
Geometry
                     common types

●   Point
    (x, y)
●   Line
    (<point>, <point1>, <point2>, …)
●   Polygon
    (<line>, <line1>, <line2>, …)
MultiGeometry
                 additional types of geometry

●   MultiPoint
    (<point>, <point1>, <point2>, ...)
●   MultiLine
    (<line>, <line1>, <line2>, ...)
●   MultiPolygon
    (<polygon>, <polygon1>, <polygon2>, ...)
Database layer
  storing spatial data
Storing data
                     spatial databases
●   SpatiaLite (SQLite)
●   MySQL
●   Oracle
●   PostGIS (PostgreSQL)
Storing data
   right choice




PostGIS
How to get geo data?
      vector data
Getting data
     vector data


OpenStreetMap
OpenStreetMap
                              stats

●   < 400 000 registered users
●   ~ 1 100 000 000 nodes (points)
●   100 000 000 ways
●   ~ 800 — 3 000 nodes added each day
●   ~ 100 000 — 300 000 ways added each day
●   More statistics:
    http://wiki.openstreetmap.org/wiki/Stats
OpenStreetMap
                              downloading ...

●   Download planet.osm
    http://wiki.openstreetmap.org/wiki/Planet.osm
●   OSM API
    http://api.openstreetmap.org/api/0.6/map?bbox=11.54,48.14,11.543,48.145

●   JOSM (download through desktop app)
    http://wiki.openstreetmap.org/wiki/JOSM
●   Third part services (GIS LAB)
    http://gis-lab.info/projects/osm-export.html
Loading data to database
>wget http://wiki.openstreetmap.org/wiki/Planet.osm
OSM2PgSQL
                                    loading data

●   osm2pgsql
    -d <db_name>
    -H <db_host>
    -U <db_user>
    -P <db_port>
    -c # create tables if needed
    -s # store tmp data in database
    -S osm.import.style # mapping style
    -k # add tags without column to an additional hstore
    -z extra_data # hstore column containing all tags that start with 'extra_data'
    RU-KRS.osm # path to OSM data file
Rendering ...
Rendering
             tool choosing




MapServer                    Mapnik
Mapnik
                       description

●   Written in C++
●   Python interface
●   OpenStreetMap, Flickr, CloudMade use mapnik
●   PostGIS, Shapefiles, GeoTIFF, OSM XML, ...
●   PNG, JPG, SVG, PDF, ...
Mapnik
map example
Layers
 intro
Mapnik
                                  code example

import mapnik

m = mapnik.Map(600,300,"+proj=latlong +datum=WGS84")
m.background = mapnik.Color('steelblue')

r = mapnik.Rule()
r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')))
r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1))

s = mapnik.Style()
s.rules.append(r)
m.append_style('World Style',s)
Mapnik
                                  code example

import mapnik

m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84")
m.background = mapnik.Color('steelblue')

r = mapnik.Rule()
r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')))
r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1))

s = mapnik.Style()
s.rules.append(r)
m.append_style('World Style',s)
Mapnik
                                  code example

import mapnik

m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84")
m.background = mapnik.Color('steelblue')

r = mapnik.Rule()
r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')))
r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'), 0.1))

s = mapnik.Style()
s.rules.append(r)
m.append_style('World Style',s)
Mapnik
                                  code example

import mapnik

m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84")
m.background = mapnik.Color('steelblue')

r = mapnik.Rule()
r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9')))
r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'), 0.1))

s = mapnik.Style()
s.rules.append(r)
m.append_style('World Style',s)
Mapnik
                             code example 2

lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84")

lyr.datasource = mapnik.Shapefile(file='world_borders.shp')

lyr.styles.append('World Style')

m.layers.append(lyr)

m.zoom_to_box(lyr.envelope())

mapnik.render_to_file(m,'world.png', 'png')
Mapnik
                             code example 2

lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84")

lyr.datasource = mapnik.Shapefile(file='world_borders.shp')

lyr.styles.append('World Style')

m.layers.append(lyr)

m.zoom_to_box(lyr.envelope())

mapnik.render_to_file(m,'world.png', 'png')
Mapnik
                             code example 2

lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84")

lyr.datasource = mapnik.Shapefile(file='world_borders.shp')

lyr.styles.append('World Style')

m.layers.append(lyr)

m.zoom_to_box(lyr.envelope())

mapnik.render_to_file(m,'world.png', 'png')
Map in browser
Mapnik
tile description
Mapnik
                       map services

●   Tile Map Service
●   Web Map Service
Mapnik
                    TMS

http: //website.com/<zoom>/<x>/<y>.png

../tiles/12/2451/1360.png
Mapnik
                             using osm scripts

●   svn export http://svn.openstreetmap.org/applications/rendering/...
●   ./generate_xml.py --password 'value' --host 'value' --port 'value'
    --user 'value' --dbname 'value'
●   MAPNIK_MAP_FILE='osm.xml' MAPNIK_TILE_DIR='tiles/'
    ./generate_tiles.py
Mapnik XML
<Map bgcolor="#b5d0d0">
<Style name="map_style">
   <Rule>
       <MaxScaleDenominator>[scale]</MaxScaleDenominator>
       <MinScaleDenominator>[scale]</MinScaleDenominator>
       <Filter>[field]='value'</Filter>
       <PointSymbolizer/>
       <LineSymbolizer/>
       <PolygonSymbolizer/>
       …
   </Rule>
</Style>
Mapnik XML
<Layer name="misc_boundaries">

<StyleName>map_style</StyleName>
<Datasource>
   <Parameter name="table">
       (select way,way_area,name,boundary from polygon
       where boundary='national_park') as boundary
   </Parameter>
   <Parameter name='dbname'>[dbname]</Parameter>
   <Parameter name='host'>[host]</Parameter>
   <Parameter name='user'>[user]</Parameter>
   …
</Datasource>
</Layer>
Tile generating



./generate_tiles.py
Got tiles, what's next?
Frontend maps
                    choosing tool

●   OpenLayers
●   GeoExt
●   Leaflet
OpenLayers
●   Most powerfull
●   Most used
●   Large community
●   OSM supported
●   OSM, Google, Yahoo maps in one string
●   TMS, WMS, WFS
●   GML, GeoJSON, GeoRSS
OpenLayers
Show time!
Thanks!
Questions?

Mais conteúdo relacionado

Mais procurados

Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and othersSpatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Henrik Ingo
 
Grails : Ordr, Maps & Charts
Grails : Ordr, Maps & ChartsGrails : Ordr, Maps & Charts
Grails : Ordr, Maps & Charts
Henk Jurriens
 

Mais procurados (20)

Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012Server side geo_tools_in_drupal_pnw_2012
Server side geo_tools_in_drupal_pnw_2012
 
OSM data in MariaDB / MySQL - All the world in a few large tables
OSM data in MariaDB / MySQL - All the world in a few large tablesOSM data in MariaDB / MySQL - All the world in a few large tables
OSM data in MariaDB / MySQL - All the world in a few large tables
 
Having fun with graphs, a short introduction to D3.js
Having fun with graphs, a short introduction to D3.jsHaving fun with graphs, a short introduction to D3.js
Having fun with graphs, a short introduction to D3.js
 
3D + MongoDB = 3D Repo
3D + MongoDB = 3D Repo3D + MongoDB = 3D Repo
3D + MongoDB = 3D Repo
 
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and othersSpatial functions in  MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
Spatial functions in MySQL 5.6, MariaDB 5.5, PostGIS 2.0 and others
 
Logging in JavaScript - Part-3
Logging in JavaScript - Part-3Logging in JavaScript - Part-3
Logging in JavaScript - Part-3
 
Grails : Ordr, Maps & Charts
Grails : Ordr, Maps & ChartsGrails : Ordr, Maps & Charts
Grails : Ordr, Maps & Charts
 
Day 6 - PostGIS
Day 6 - PostGISDay 6 - PostGIS
Day 6 - PostGIS
 
Scala meetup - Intro to spark
Scala meetup - Intro to sparkScala meetup - Intro to spark
Scala meetup - Intro to spark
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGIS
 
MongoDB GeoSpatial Feature
MongoDB GeoSpatial FeatureMongoDB GeoSpatial Feature
MongoDB GeoSpatial Feature
 
Geospatial and MongoDB
Geospatial and MongoDBGeospatial and MongoDB
Geospatial and MongoDB
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
d3 is cool
d3 is coold3 is cool
d3 is cool
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)
 
Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.Gems of GameplayKit. UA Mobile 2017.
Gems of GameplayKit. UA Mobile 2017.
 
Efek daun
Efek daunEfek daun
Efek daun
 
Snow
SnowSnow
Snow
 

Destaque

ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัยภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
miniindy
 
GeoDjango in a nutshell
GeoDjango in a nutshellGeoDjango in a nutshell
GeoDjango in a nutshell
Django Stars
 
ภารกิจ+กา..
ภารกิจ+กา..ภารกิจ+กา..
ภารกิจ+กา..
miniindy
 
ทบทวนวิชา..
ทบทวนวิชา..ทบทวนวิชา..
ทบทวนวิชา..
miniindy
 
สรุปเนื้อหาวิชาการทหารกองทัพเรือ
สรุปเนื้อหาวิชาการทหารกองทัพเรือสรุปเนื้อหาวิชาการทหารกองทัพเรือ
สรุปเนื้อหาวิชาการทหารกองทัพเรือ
miniindy
 
WHY gowellgo
WHY gowellgoWHY gowellgo
WHY gowellgo
didemc
 
ABOUT gowellgo
ABOUT gowellgoABOUT gowellgo
ABOUT gowellgo
didemc
 
ความสัมพันธ์ ผบ.
ความสัมพันธ์ ผบ.ความสัมพันธ์ ผบ.
ความสัมพันธ์ ผบ.
miniindy
 
ทบทวนวิชาวิทยาการทหาร51
ทบทวนวิชาวิทยาการทหาร51ทบทวนวิชาวิทยาการทหาร51
ทบทวนวิชาวิทยาการทหาร51
miniindy
 

Destaque (20)

Grace Photo Show
Grace  Photo ShowGrace  Photo Show
Grace Photo Show
 
HotelToWeb
HotelToWebHotelToWeb
HotelToWeb
 
CSC Screeding
CSC ScreedingCSC Screeding
CSC Screeding
 
HTWRateHunter
HTWRateHunterHTWRateHunter
HTWRateHunter
 
Hotel To Web Katalog
Hotel To Web KatalogHotel To Web Katalog
Hotel To Web Katalog
 
Vœux 2010 de la Mairie
Vœux 2010 de la MairieVœux 2010 de la Mairie
Vœux 2010 de la Mairie
 
Nj 09 Q4 Paul Kadzielawa
Nj 09 Q4 Paul KadzielawaNj 09 Q4 Paul Kadzielawa
Nj 09 Q4 Paul Kadzielawa
 
ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัยภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
ภารกิจ การจัด และการดำเนินงานทางทหาร สำหรับบรรยายมหาลัย
 
GeoDjango in a nutshell
GeoDjango in a nutshellGeoDjango in a nutshell
GeoDjango in a nutshell
 
I P I A L E S
I P I A L E SI P I A L E S
I P I A L E S
 
หลักการสงคราม
หลักการสงครามหลักการสงคราม
หลักการสงคราม
 
ภารกิจ+กา..
ภารกิจ+กา..ภารกิจ+กา..
ภารกิจ+กา..
 
ทบทวนวิชา..
ทบทวนวิชา..ทบทวนวิชา..
ทบทวนวิชา..
 
สรุปเนื้อหาวิชาการทหารกองทัพเรือ
สรุปเนื้อหาวิชาการทหารกองทัพเรือสรุปเนื้อหาวิชาการทหารกองทัพเรือ
สรุปเนื้อหาวิชาการทหารกองทัพเรือ
 
HotelToWeb Catalogue
HotelToWeb CatalogueHotelToWeb Catalogue
HotelToWeb Catalogue
 
WHY gowellgo
WHY gowellgoWHY gowellgo
WHY gowellgo
 
ABOUT gowellgo
ABOUT gowellgoABOUT gowellgo
ABOUT gowellgo
 
HotelToWeb
HotelToWebHotelToWeb
HotelToWeb
 
ความสัมพันธ์ ผบ.
ความสัมพันธ์ ผบ.ความสัมพันธ์ ผบ.
ความสัมพันธ์ ผบ.
 
ทบทวนวิชาวิทยาการทหาร51
ทบทวนวิชาวิทยาการทหาร51ทบทวนวิชาวิทยาการทหาร51
ทบทวนวิชาวิทยาการทหาร51
 

Semelhante a Pycon2011

Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGIS
Xander Bakker
 
Sapo GIS Hands-On
Sapo GIS Hands-OnSapo GIS Hands-On
Sapo GIS Hands-On
codebits
 
Gis SAPO Hands On
Gis SAPO Hands OnGis SAPO Hands On
Gis SAPO Hands On
codebits
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDB
Takahiro Inoue
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
CoLab Athens
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
Ilya Rosenfeld
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
偉格 高
 

Semelhante a Pycon2011 (20)

Python en la Plataforma ArcGIS
Python en la Plataforma ArcGISPython en la Plataforma ArcGIS
Python en la Plataforma ArcGIS
 
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
 
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
SF Big Analytics 20191112: How to performance-tune Spark applications in larg...
 
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRasterFOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
FOSS4G 2010 PostGIS Raster: an Open Source alternative to Oracle GeoRaster
 
2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator
 
2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator2017 02-07 - elastic & spark. building a search geo locator
2017 02-07 - elastic & spark. building a search geo locator
 
10. R getting spatial
10.  R getting spatial10.  R getting spatial
10. R getting spatial
 
What are customers building with new Bing Maps capabilities
What are customers building with new Bing Maps capabilitiesWhat are customers building with new Bing Maps capabilities
What are customers building with new Bing Maps capabilities
 
How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...
 
Sapo GIS Hands-On
Sapo GIS Hands-OnSapo GIS Hands-On
Sapo GIS Hands-On
 
Gis SAPO Hands On
Gis SAPO Hands OnGis SAPO Hands On
Gis SAPO Hands On
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDB
 
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
 
R getting spatial
R getting spatialR getting spatial
R getting spatial
 
Geo script opengeo spring 2013
Geo script opengeo spring 2013Geo script opengeo spring 2013
Geo script opengeo spring 2013
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping Visualization
 
How to Hack a Road Trip with a Webcam, a GSP and Some Fun with Node
How to Hack a Road Trip  with a Webcam, a GSP and Some Fun with NodeHow to Hack a Road Trip  with a Webcam, a GSP and Some Fun with Node
How to Hack a Road Trip with a Webcam, a GSP and Some Fun with Node
 
Graph computation
Graph computationGraph computation
Graph computation
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Pycon2011

  • 1. GIS, Python and company Igor Pochechuev 22-23 October, 2011 Kyiv, Ukraine
  • 2.
  • 3. Content ● What is geometry? geometry formats ● How to store geo data? spatial databases ● Where we can get geo data? ● Render it! ● Demo
  • 4. General provisions what we got
  • 5. Geometry formats ● WKT, WKB ● KML, GML (xml based) ● GeoJSON (json based) ● Shapefile (ESRI open specification) ● etc.
  • 6. Geometry common types ● Point (x, y) ● Line (<point>, <point1>, <point2>, …) ● Polygon (<line>, <line1>, <line2>, …)
  • 7. MultiGeometry additional types of geometry ● MultiPoint (<point>, <point1>, <point2>, ...) ● MultiLine (<line>, <line1>, <line2>, ...) ● MultiPolygon (<polygon>, <polygon1>, <polygon2>, ...)
  • 8. Database layer storing spatial data
  • 9. Storing data spatial databases ● SpatiaLite (SQLite) ● MySQL ● Oracle ● PostGIS (PostgreSQL)
  • 10. Storing data right choice PostGIS
  • 11. How to get geo data? vector data
  • 12. Getting data vector data OpenStreetMap
  • 13. OpenStreetMap stats ● < 400 000 registered users ● ~ 1 100 000 000 nodes (points) ● 100 000 000 ways ● ~ 800 — 3 000 nodes added each day ● ~ 100 000 — 300 000 ways added each day ● More statistics: http://wiki.openstreetmap.org/wiki/Stats
  • 14. OpenStreetMap downloading ... ● Download planet.osm http://wiki.openstreetmap.org/wiki/Planet.osm ● OSM API http://api.openstreetmap.org/api/0.6/map?bbox=11.54,48.14,11.543,48.145 ● JOSM (download through desktop app) http://wiki.openstreetmap.org/wiki/JOSM ● Third part services (GIS LAB) http://gis-lab.info/projects/osm-export.html
  • 15. Loading data to database
  • 17. OSM2PgSQL loading data ● osm2pgsql -d <db_name> -H <db_host> -U <db_user> -P <db_port> -c # create tables if needed -s # store tmp data in database -S osm.import.style # mapping style -k # add tags without column to an additional hstore -z extra_data # hstore column containing all tags that start with 'extra_data' RU-KRS.osm # path to OSM data file
  • 19. Rendering tool choosing MapServer Mapnik
  • 20. Mapnik description ● Written in C++ ● Python interface ● OpenStreetMap, Flickr, CloudMade use mapnik ● PostGIS, Shapefiles, GeoTIFF, OSM XML, ... ● PNG, JPG, SVG, PDF, ...
  • 23. Mapnik code example import mapnik m = mapnik.Map(600,300,"+proj=latlong +datum=WGS84") m.background = mapnik.Color('steelblue') r = mapnik.Rule() r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1)) s = mapnik.Style() s.rules.append(r) m.append_style('World Style',s)
  • 24. Mapnik code example import mapnik m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84") m.background = mapnik.Color('steelblue') r = mapnik.Rule() r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'),0.1)) s = mapnik.Style() s.rules.append(r) m.append_style('World Style',s)
  • 25. Mapnik code example import mapnik m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84") m.background = mapnik.Color('steelblue') r = mapnik.Rule() r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'), 0.1)) s = mapnik.Style() s.rules.append(r) m.append_style('World Style',s)
  • 26. Mapnik code example import mapnik m = mapnik.Map(600, 300, "+proj=latlong +datum=WGS84") m.background = mapnik.Color('steelblue') r = mapnik.Rule() r.symbols.append(mapnik.PolygonSymbolizer(mapnik.Color('#f2eff9'))) r.symbols.append(mapnik.LineSymbolizer(mapnik.Color('rgb(50%,50%,50%)'), 0.1)) s = mapnik.Style() s.rules.append(r) m.append_style('World Style',s)
  • 27. Mapnik code example 2 lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84") lyr.datasource = mapnik.Shapefile(file='world_borders.shp') lyr.styles.append('World Style') m.layers.append(lyr) m.zoom_to_box(lyr.envelope()) mapnik.render_to_file(m,'world.png', 'png')
  • 28. Mapnik code example 2 lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84") lyr.datasource = mapnik.Shapefile(file='world_borders.shp') lyr.styles.append('World Style') m.layers.append(lyr) m.zoom_to_box(lyr.envelope()) mapnik.render_to_file(m,'world.png', 'png')
  • 29. Mapnik code example 2 lyr = mapnik.Layer('world', "+proj=latlong +datum=WGS84") lyr.datasource = mapnik.Shapefile(file='world_borders.shp') lyr.styles.append('World Style') m.layers.append(lyr) m.zoom_to_box(lyr.envelope()) mapnik.render_to_file(m,'world.png', 'png')
  • 32. Mapnik map services ● Tile Map Service ● Web Map Service
  • 33. Mapnik TMS http: //website.com/<zoom>/<x>/<y>.png ../tiles/12/2451/1360.png
  • 34. Mapnik using osm scripts ● svn export http://svn.openstreetmap.org/applications/rendering/... ● ./generate_xml.py --password 'value' --host 'value' --port 'value' --user 'value' --dbname 'value' ● MAPNIK_MAP_FILE='osm.xml' MAPNIK_TILE_DIR='tiles/' ./generate_tiles.py
  • 35. Mapnik XML <Map bgcolor="#b5d0d0"> <Style name="map_style"> <Rule> <MaxScaleDenominator>[scale]</MaxScaleDenominator> <MinScaleDenominator>[scale]</MinScaleDenominator> <Filter>[field]='value'</Filter> <PointSymbolizer/> <LineSymbolizer/> <PolygonSymbolizer/> … </Rule> </Style>
  • 36. Mapnik XML <Layer name="misc_boundaries"> <StyleName>map_style</StyleName> <Datasource> <Parameter name="table"> (select way,way_area,name,boundary from polygon where boundary='national_park') as boundary </Parameter> <Parameter name='dbname'>[dbname]</Parameter> <Parameter name='host'>[host]</Parameter> <Parameter name='user'>[user]</Parameter> … </Datasource> </Layer>
  • 39. Frontend maps choosing tool ● OpenLayers ● GeoExt ● Leaflet
  • 40. OpenLayers ● Most powerfull ● Most used ● Large community ● OSM supported ● OSM, Google, Yahoo maps in one string ● TMS, WMS, WFS ● GML, GeoJSON, GeoRSS