Overview
Public administrations usually provide maps and public records in shapefile formats.
Shapefile
The shapefile is a geospatial vector data format introduced in the early 90’s . Actually, it is a collection of three files:
- `.shp: binary shapes (polygon…), the geometry itself.
.dbf
: data of shapes or records. In dBase format..shx
: shape index format for quicker indexing.
Other files like .proj
, .shp.xml
, .sbn
… may be included.
In this example we are going to use the Spanish census section shapefile (INE Cartografía digitalizada):
Despite being useful for many purposes, shapefiles are not the best option for human reading or web visualization. The main problem is the size of the .shp
files:
109Mb of shapes and 11Mb of data is not the best way to represent a map in a browser.
GeoJSON & TopoJSON
GeoJSON, based on JSON, allows us to store collections of geometric data types (including their non-spatial attributes) in one central structure.
A notable extension of GeoJSON is TopoJSON, that encodes geospatial topology and provides smaller file sizes (up to 80% reduction).
How to convert shapefiles into json type of files?
Web browser
- Mapsharer: Best one. Shapefile, geojson, topojson, csv, svg & map representation
- geojson-topojson: GeoJSON <-> TopoJSON
- Distillery: GeoJSON -> TopoJSON & Map representation
NodeJS & CL
Mike Bostock wrote wonderful long posts with neat examples: https://medium.com/@mbostock/command-line-cartography-part-1-897aa8f8ca2c
Python
There are several gist solutions with different python libraries: