0
I wanted to create an npm package in which we would have a function that as input we would give the geo-coordinates and as output we would give the parish, county and district of Portugal (official administrative division of Portugal).
var res = getAdministrativeDivisionsPT(lat, long);
console.log(res) // {distrito: 'Leiria', concelho: 'Alcobaça', freguesia: 'Cós'}
I’ve been investigating this all day yesterday and I leave here the conclusions I’ve come to so far:
We have to use two libraries. We have to use the npm library shpjs
to open the official zip and convert it to Geojson and then we have to use the library d3-geo
to know if it is contained in the municipality. We still have to use quadtree because it is not efficient to be iterating through all municipalities to know whether or not the point is within the municipality.
Does anyone know how to do it in Javascript?
have you tried anything? put in the question the code you already have... in the links mentioned have examples, it is easier for the community to help with a more specific problem :)
– Ricardo Pontual