SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
TeamupDjangoand
Webmapping
DjangoConEurope2014
MathieuLeplatre
@leplatrem
www.makina-corpus.com
Maingoals...
●
Webmappingshouldbesimple
●
GoogleMapsshouldbecomeunusual
●
Demystifycartography!
Mainfocus...
●
Fundamentalsofcartography(projections,PostGIS)
●
Webmapping(GeoJSON,Leaflet)
●
Djangotoolbox(a.k.a.GeoDjango)
Fundamentalsofcartography
Coordinates :positiononEarth
●
Longitude(x) – Latitude (y)
●
Decimaldegrees(-180 +180, -90 +90)→ →
●
GPS
Geodesy :shapeoftheEarth
Ellipsoid (GPS,WGS84)
Illustration:http://mapschool.io
Projections
●
Equations (lat/lng pixels)↔
●
Representationonaplane ( compromises)→
●
Spatialreferencetransformation
Illustration:http://mapschool.io
SpatialReferences
●
Coordinatesystem(cartesian)
●
Units(degrees,meters)
●
Mainaxis(equator,Greenwich)
●
Ellipsoid,geoid (WGS84)
●
Conical, cylindrical,conformal,...
●
…
Store  WGS84→ (GPS,srid=4326)
Display →Mercator(GoogleMaps,srid=3857)
Vectordata
●
Point(x,y,z)
●
Line(orderedlistofpoints)
●
Polygon(enveloppe+holes)
Illustration:http://mapschool.io
Rasterdata
●
~Images
●
Mapbackgrounds(satellite,plan,…)
●
Atimetrydata(DEM)
Illustration:http://mapschool.io
APostGISdatabase
●
Columntypes(Point,LineString,Polygon,…Raster...)
●
Geographicfunctions(distance,area,extents...)
●
SpatialIndexes(rectanglestrees...)
$ sudo apt-get install postgis
$ psql -d mydatabase
> CREATE EXTENSION postgis;
Examples (1/2)
CREATE TABLE island (
label VARCHAR(128),
code INTEGER,
geom geometry(Polygon, 4326)
)
Examples (1/2)
CREATE TABLE island (
label VARCHAR(128),
code INTEGER,
geom geometry(Polygon, 4326)
)
Usual table
Usual
columnsVector
geometry
column
Geometry type Spatial
Reference
Examples (2/2)
SELECT room.id
FROM room, island
WHERE ST_Intersects(room.geom,
island.geom)
Spatial join
INSERT INTO room (geom) VALUES (
'SRID=4326;POINT(3.12, 43.1)'::geometry
)
EWKT format
PostgreSQL cast
Webmapping
Webmapanatomy...
●
JavaScript+DOM
●
Initializationofa<div>
●
« Layers »
Webmapanatomy...
●
JavaScript+DOM
●
Initializationofa<div>
●
« Layers »
●
<img> (Backgrounds)
●
Vector SVG→
●
Lat/Long pixels→ (CSS)
●
DOMEvents (interactions)
Leafletexample
<script src="leaflet.js"></script>
<link rel="stylesheet" href="leaflet.css" />
<div id="simplemap"></div>
<script>
var map = L.map('simplemap')
.fitWorld();
L.tileLayer('http://tile.osm.org/{z}/{x}/{y}.png')
.addTo(map);
L.marker([43.07, -5.78])
.addTo(map);
</script>
http://leafletjs.com
Seealso...
D3
●
SVG
●
Cooldataviz
●
Exoticmapprojections
OpenLayers3
●
Canvas
●
GIS-oriented(advanceduse-cases)
Formats(1/2)
●
Rasterimages(PNGouJPG)
●
z/x/y.png
●
Projection3857(Mercator,GoogleMaps)
→Colddata
(tileprovider)
…→ orwarm
(renderingengine)
Formats(2/2)
●
GeoJSONforvectordata
●
Projection4326(GPS,WGS84)
●
Interactive ?
●
Volume ?
●
Frequency ?
→Dynamic
(fromdatabase)
SELECT
ST_AsGeoJSON(geom)
FROM ...
Nothingnew...
WebServer Browser
PostGIS Django
Rendering
Engine
Vector
overlay
Raster
overlay
Raster
background
Images
z/x/y.png
GeoJSON
z/x/y.png, UTFGrid, ...
GeoDjango
DjangoEcosystemforCartography
fromdjango.contrib.gisimport...
●
Modelsfields(syncdb)
●
GeoQuerySet(spatialqueries)
●
Formfields(Django1.6)
●
Systemlibrariesdeps(GEOS,GDAL)
●
Widgets&AdminSite(OpenLayers2)
Examples(1/2)
from django.contrib.gis.db import (
models as gismodels
)
class Island(gismodels.Model):
label = models.CharField(max_length=128),
code = models.IntegerField(),
geom = gismodels.PolygonField(srid=4326)
objects = gismodels.GeoManager()
Examples(2/2)
from django.contrib.gis.geos import Polygon
embiez = Island(label='Embiez',
geom=Polygon(((0.34, 0.44),
(0.36, 0.42), …)))
~
from django.contrib.gis.geos import fromstr
myroom = fromstr('SRID=4326;POINT(3.12, 43.1)')
Island.objects.filter(geom__intersects=myroom)
●
Views (Class-based)
●
Generalization&approximation (lessdetailsanddecimals)
●
Serialization (dumpdata, loaddata)
●
Modelfields(text,noGIS!)
●
Vectortiles(hugedatasets)
django-geojson
from djgeojson.views import GeoJSONLayerView
urlpatterns = patterns('',
url(r'^buildings.geojson$',
GeoJSONLayerView.as_view(model=Building))
)
django-leaflet
●
Quick-startkit {% leafletmap "djangocon" %}
●
Assets(collecstatic)
●
Easypluginsintegration
●
Globalconfiguration (settings.py,plugins,...)
●
Leafletprojectionsmachinery (reprojection)
django-leaflet(view)
{% load leaflet_tags %}
...
{% leaflet_js %}
{% leaflet_css %}
</head>
<body>
{% leafletmap "buildingmaps" callback="initMap" %}
<script type="text/javascript">
function initMap(map) {
// Ajax Load
$.getJSON("{% url app:layer %}", function (data) {
// Add GeoJSON to the map
L.geoJSON(data).addTo(map);
});
}
GeoJSON
view
LAYER
django-leaflet(edit)
Forms
●
Fields(Django1.6+API)
●
Widgets (hidden<textarea>+Leaflet.draw)
class BuildingForm(forms.ModelForm):
class Meta:
model = Building
widgets = {'geom': LeafletWidget()}
fields = ('code', 'geom')
●
LeafletAdminSite
admin.site.register(Building, LeafletGeoAdmin)
SCREENSHOTFORM
Conclusion
AnyonecandoWebmapping...
Cartographyissimple.
●
Justsomespecialdatatypes
●
FollowsDjangoconventions
●
Fewlinesofcode
Illustration:ChefGusteau,PixarInc.
…withappropriatetoolsandstrategies!
Cartographyishard.
●
Performance(Web)
●
Volume(precision)
●
Datarefreshrate(caching)
●
Userstoriestoofarfromdata (modeling)
Illustration:AntonEgo,PixarInc.
MakinaCorpus -FreeSoftware|Cartography|Mobile
Questions ?
...andanswers !
PostGIS -Leaflet–JavaScript
http://makina-corpus.com

Mais conteúdo relacionado

Semelhante a Team up Django and Web mapping - DjangoCon Europe 2014

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
 

Semelhante a Team up Django and Web mapping - DjangoCon Europe 2014 (7)

Geolocation and Mapping
Geolocation and MappingGeolocation and Mapping
Geolocation and Mapping
 
Geo search introduction
Geo search introductionGeo search introduction
Geo search introduction
 
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
 
HTML5勉強会#23_GeoHex
HTML5勉強会#23_GeoHexHTML5勉強会#23_GeoHex
HTML5勉強会#23_GeoHex
 
GeoDjango & HTML5 Geolocation
GeoDjango & HTML5 GeolocationGeoDjango & HTML5 Geolocation
GeoDjango & HTML5 Geolocation
 
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
 
Large Scale Geo Processing on Hadoop
Large Scale Geo Processing on HadoopLarge Scale Geo Processing on Hadoop
Large Scale Geo Processing on Hadoop
 

Mais de Makina Corpus

Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMillCréez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Makina Corpus
 

Mais de Makina Corpus (19)

Happy hacking with Plone
Happy hacking with PloneHappy hacking with Plone
Happy hacking with Plone
 
Développer des applications mobiles avec phonegap
Développer des applications mobiles avec phonegapDévelopper des applications mobiles avec phonegap
Développer des applications mobiles avec phonegap
 
Running a Plone product on Substance D
Running a Plone product on Substance DRunning a Plone product on Substance D
Running a Plone product on Substance D
 
Why CMS will not die
Why CMS will not dieWhy CMS will not die
Why CMS will not die
 
Publier vos données sur le Web - Forum TIC de l'ATEN 2014
Publier vos données sur le Web -  Forum TIC de l'ATEN 2014Publier vos données sur le Web -  Forum TIC de l'ATEN 2014
Publier vos données sur le Web - Forum TIC de l'ATEN 2014
 
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMillCréez votre propre fond de plan à partir de données OSM en utilisant TileMill
Créez votre propre fond de plan à partir de données OSM en utilisant TileMill
 
Petit déjeuner "Les bases de la cartographie sur le Web"
Petit déjeuner "Les bases de la cartographie sur le Web"Petit déjeuner "Les bases de la cartographie sur le Web"
Petit déjeuner "Les bases de la cartographie sur le Web"
 
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
Petit déjeuner "Développer sur le cloud, ou comment tout construire à partir ...
 
CoDe, le programme de développement d'applications mobiles de Makina Corpus
CoDe, le programme de développement d'applications mobiles de Makina Corpus CoDe, le programme de développement d'applications mobiles de Makina Corpus
CoDe, le programme de développement d'applications mobiles de Makina Corpus
 
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
Petit déjeuner "Alternatives libres à GoogleMaps" du 11 février 2014 - Nantes...
 
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembrePetit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
Petit déjeuner "Les nouveautés de la cartographie en ligne" du 12 décembre
 
Alternatives libres à Google Maps
Alternatives libres à Google MapsAlternatives libres à Google Maps
Alternatives libres à Google Maps
 
Atelier "Les nouveautés de la cartographie en ligne"
Atelier "Les nouveautés de la cartographie en ligne"Atelier "Les nouveautés de la cartographie en ligne"
Atelier "Les nouveautés de la cartographie en ligne"
 
Importing Wikipedia in Plone
Importing Wikipedia in PloneImporting Wikipedia in Plone
Importing Wikipedia in Plone
 
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
Petit Déjeuner : HTML5 et CSS3, les interfaces de demain.
 
Geotrek
GeotrekGeotrek
Geotrek
 
Plomino
Plomino Plomino
Plomino
 
Des cartes d'un autre monde - DjangoCong 2012
Des cartes d'un autre monde - DjangoCong 2012Des cartes d'un autre monde - DjangoCong 2012
Des cartes d'un autre monde - DjangoCong 2012
 
Solutions libres alternatives à Google Maps
Solutions libres alternatives à Google MapsSolutions libres alternatives à Google Maps
Solutions libres alternatives à Google Maps
 

Último

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+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...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Team up Django and Web mapping - DjangoCon Europe 2014