SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
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

Contenu connexe

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
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...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
[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
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 

Team up Django and Web mapping - DjangoCon Europe 2014