Skip to content
vic

defvol/marco

:earth_americas: Geolocate places from your datasets

defvol/marco.json
{
"createdAt": "2016-04-25T11:52:21Z",
"defaultBranch": "master",
"description": ":earth_americas: Geolocate places from your datasets",
"fullName": "defvol/marco",
"homepage": "",
"language": "JavaScript",
"name": "marco",
"pushedAt": "2022-03-26T09:53:46Z",
"stargazersCount": 9,
"topics": [],
"updatedAt": "2024-04-02T19:27:51Z",
"url": "https://github.com/defvol/marco"
}

Build Status

Transform a CSV dataset into GeoJSON, by matching names of places against a line-delimited GeoJSON source of truth.

Additional layers suitable for a data processing pipeline are included.

demo

Bring your own

The PoC looks for administrative boundaries in Mexico from Marco Geoestadístico Nacional, but you could easily swap to other sources, like OSM.

From the command line

To get the polygon of a city in Mexico, type:

Terminal window
% node cli.js --municipality 'Mexicali'
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"place": {
"municipality": "Mexicali"
}
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [...]
}
}
]
}

Stream a CSV file and output line-delimited GeoJSON FeatureCollection:

✗ cat test/fixtures/dataset.csv | node cli.js -sc > matches.json
✗ wc -l matches.json
6 matches.json
✗ head -n1 matches.json
{"type":"FeatureCollection","features":[
✗ tail -n1 matches.json
]}
✗ cat matches.json | jq '.features[].properties.NOM_ENT'
"Aguascalientes"
"Baja California"
"Nuevo León"

[recommended] Simplify GeoJSON

Terminal window
% npm install simplify-geojson -g
% cat test/fixtures/dataset.csv | node cli.js --state --collection | simplify-geojson -t 0.01 > map.json

Commands:

% node cli.js --help

Download INEGI data and transform it into GeoJSON:

Terminal window
% ./data.sh -d data -t data

Install dependencies

Terminal window
% npm install

Transform a CSV to a choropleth-ready GeoJSON:

Terminal window
% cat poblacion-estatal.csv | node marco.js --state

Make a map out of an article

Terminal window
% cat your-article.doc | node marco.js --centroid --municipality | geojsonio

See: geojsonio-cli

Find the distance between my city and a hurricane!

Terminal window
% wget EP202015_005adv_TRACK.kml | togeojson > hurricane.json
% node marco.js 'Puerto Escondido' --centroid --municipality | turf-distance hurricane.json

A pluggable geospatial toolset right in your terminal.