Last active
May 2, 2020 11:13
-
-
Save daleharvey/01d1780f7343251f6d9c5bd69212e8a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run.py | |
import geocode | |
geocoder = geocode.Geocoder() | |
f = open("mls.csv", "r") | |
r = open("mls.res", "a") | |
for x in f: | |
[long, lat] = x.strip().split(",") | |
region = geocoder.region(float(lat), float(long)) | |
r.write("%s,%s,%s\n" % (lat, long, region)) | |
r.close() | |
// Edited getRegion | |
let points = "resource://search-extensions/mls.csv"; | |
let preq = await fetch(points); | |
let p = await preq.text(); | |
let url = "resource://search-extensions/regions_buffer.geojson"; | |
let req = await fetch(url); | |
let json = await req.json(); | |
await Promise.all( | |
p.split("\n").map(async x => { | |
var lon, lat; | |
[lon, lat] = x.replace(/^\s+|\s+$/g, "").split(","); | |
let region = await this.getRegionFeature( | |
{ | |
lat: parseFloat(lat), | |
long: parseFloat(lon), | |
}, | |
json); | |
dump(`${lon},${lat},${region.properties.alpha2}\n`); | |
return [lon, lat, region.properties.alpha2]; | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment