-
Notifications
You must be signed in to change notification settings - Fork 0
Sample Code and Tutorials
There are a number of services that provide a simple HTTP interface for querying of geographic data. These include the Web Map Service, the Web Feature Service and the Web Coverage Service.
Visit the Geo Query Builder to simplify the process of building queries to retrieve the data you need from a WMS/WFS server. Or take a look at the some sample queries below.
The Web Map Service can be used for requesting map images and tiles from geospatial databases. Multiple layers can be requested at once or requested as transparent images to layer with other images.For example an image depicting the Australian state boundaries.
JSON object representing the parameters:
{
"service": "WMS",
"request": "GetMap",
"bbox": "96.816941408,-43.740509603,159.109219008,-9.142175977",
"layers": "admin_bnds_abs:STE_2011_AUST",
"width": 360,
"height": 200,
"format": "image/png"
}
Note that all of the above parameters are required in order to retrieve an image.
The bounding box (bbox) is defined as the coordinates for west, south, east, north
.
JSON object representing the parameters:
{
"service": "WMS",
"request": "GetMap",
"bbox": "113.361663818359,-43.4303932189941,153.504867553711,-11.8729591369629",
"layers": "Infrastructure:mineareas,Transport:railways",
"width": 254,
"height": 200,
"format": "image/png"
}
Multiple layers can be specified simply by adding commas between multiple layer names.
The Web Feature Service can be used to retrieve data sets from geospatial databases. It can return geometry as a series of points and polygons with the properties of that geometry. For example, Australian states geometry with the state names and population as properties.
{
"service": "WFS",
"request": "GetFeature",
"typeName": "admin_bnds_abs:STE_2011_AUST",
"bbox": "-43.740509603,96.816941408,-9.142175977,159.109219008", // Optional
"maxFeatures": 50, // Optional, but beware of large amounts of data
"outputFormat": "json"
}
Note that all of the above parameters (except maxFeatures and bbox) are required in order to retrieve a feature set.
The bounding box (bbox) is defined as the coordinates for south, west, north, east
.
If you want to know the services, requests and format types that a web service provides there's a standard for querying for this information. This involves setting the request
parameter to getCapabilities
.
http://geospace.research.nicta.com.au:8080/admin_bnds/ows?service=WMS&request=GetCapabilities
{
"service": "WMS",
"request": "GetCapabilities"
}
http://geospace.research.nicta.com.au:8080/admin_bnds/ows?service=WFS&request=GetCapabilities
{
"service": "WFS",
"request": "GetCapabilities"
}
D3 is a helpful library for many types of visualization. Particularly for geographic visualization as it includes a built in geo module for dealing with GeoJSON and geographical projections.
Here are some useful samples and tutorials on how to use D3 for geospatial data:
- Introduction to GeoJSON and D3 Mapping
- D3 mapping tutorial
- A US simple map
- An orthographic world map
- 3D visualization with D3 and Cesium
Leaflet is a modern open-source JavaScript library for mobile-friendly interactive maps.
Leaflet has its own series of tutorials on creating interactive maps.
There is a mobile example using Leaflet with Cordova that demonstrates visualising a WMS layer from a geoserver. There is also a live demo that runs in a browser.
Some relevant C++ libraries:
- [boost] (http://www.boost.org/) This is an essential, makes up what the standard library is lacking.
- [CGAL] (http://www.cgal.org/) Great collection of geometric algorithms.
- [Cinder] (http://libcinder.org/) Up-and-coming library for creative coding. Great for visualisation.
- [openFrameworks] (http://www.openframeworks.cc/) Great library for coding multimedia applications.
- [REST SDK] (http://casablanca.codeplex.com/) Interfacing with web APIs.
- [SFML] (http://www.sfml-dev.org/) Another multimedia application coding library.
- [VTK] (http://www.vtk.org/) Mature and powerful visualisation toolkit.
Some Python tools that might be useful for manipulating geospatial data:
- [NumPy/SciPy] (http://www.scipy.org/) Python numeric computation
- pyshp Python Shapefile Library for ESRI shapefiles
- [gdal] (http://www.gdal.org/) Geospatial Data Abstraction Library for reading raster data
- [netcdf4-python] (http://code.google.com/p/netcdf4-python/) Reading Netcdf-4 files
- [Matplotlib] (http://matplotlib.org/) Python plotting
- [Basemap] (http://matplotlib.org/basemap/) Geospatial/Cartographic extensions for Matplotlib
See the Git repository for some examples of using Basemap to plot pointcloud, shapefile and rastered data in python.