-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added geocoding function #50
Conversation
Thanks for the contribution @mtravis! Looks like the build is failing - I think you need to add the osmnx library to the requirements.txt so it gets installed. Any chance you could add some tests for it? We've now got a test framework, and it'd be good to start to use it. Starting as a function makes sense. I'd love to understand a bit more how it works:
I wouldn't see having I think we can have the CLI handle the difference, and then have the 'download' function just take the output. We could shift download to require WKT instead of GeoJSON (and translate to wkt in the cli function), or else have your function output GeoJSON. Ultimately I think we might want to allow different geocoding options (including letting users add their own api keys), since I know of no perfect free geocoder, though I've not tried this one yet. But happy to merge this once the tests are passing, and ideally with a test so we get into that habit. |
Hi both, First of all: off-topic, but I'm not entirely sure what the SQL CLI command is for that you've linked, @mtravis. There seems to be overlap with I agree with @cholmes that there is value in adding the geocoding functionality to @cholmes has some valid points - the package seems to be wrapping the Nominatim API which I've used before. It's a simple REST API that I think works quite well. It should also be possible to return exact geometry instead of bbox. It is worth having a look at the usage policy though - I don't think there is a risk that we're exceeding the rate limit but will be good to keep in mind that they're not providing a free service without any restrictions. I know this is just a draft/conversation starter but eventually the osmnx package would have to be added to Cheers |
@cholmes thanks for the feedback. I've added my answers inline below.
Sure, I'll add those next. May need some help setting up the tests.
It calls the Nominatim API
I'm not sure it has fuzzy searching. If you use this as an example on the main OSM site which uses nominatim then
Sure that's definitely possible, in fact I was trying getting that to start with but was trying to get around having a complex geometry returned. Perhaps the default could be the actual polygon geometry and then we have a --bbox_only option?
I shouldn't have used negate here as I didn't acutally mean not have geojson at all just that having geocode meant it wasn't always necessary
I'll look into this. It might be easiest to get the geocode function output to geojson for now.
I can think of a couple of options we could e.g. Geocage. |
Ah, right. I was thinking the sql command was called, but you're right, it's just a remnant of some previous debugging. My first attempt at 'download' revealed that I had an error in my quadkey production code, so I used the sql function to debug it (before I had the generate_sql option). Left it in as a util function, but seems like we should either actually use it as the util function for get_buildings or else kill it, so it's not in there confusing things. |
I've attempted to add an option for geocode but I've struggled with that and now the tests are failing . I'm a bit lost on how to implement new arguments or options in click. Should we create a completely new argument for geocode and get the wkt directly from there? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felix-schott Thanks for reviewing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felix-schott thanks
@felix-schott I've updated the geocode function so that it returns geojson and made some other changes. Plus I added a test for the geocode function and when I run that locally it works ok. Looks like the checks for the ubuntu machines are failing though. |
cheers, i'm having a look tomorrow! |
Great. I was wondering how it's possible to test the whole app locally i.e. run |
…ositional params to kwarg, rebasing
hi @mtravis, i pushed some changes, most importantly a cli test for there a few things to be discussed here, i had to change |
it's most likely failing because I provided county_code UK instead of GB! it's late... task for tomorrow :) |
@felix-schott I've updated the test now so it uses GB. |
Just tested by version locally and it works!
I'm going to do some more testing through out the day. Thanks for your fixes @felix-schott |
great, @mtravis! only two things left imo: might be a good idea to update the README to reflect the changes. not sure if @cholmes would like to do this as part of a new release or if we want to include it in this PR. then, equally not quite sure if we came to a conclusion re bbox vs actual geometry. currently it uses bbox. i do think as a default, actual geometry or simplified geometry (https://shapely.readthedocs.io/en/stable/reference/shapely.simplify.html) would be better. depends on the performance benefit of bbox vs simplified geom vs full geom. might be worth doing some benchmarking? finally @cholmes might have some thoughts on the changes proposed here before this gets merged? summary:
still to do:
|
Thanks @felix-schott I agree the simplified geometry will probably work best. I'll apply this tomorrow. |
I've been testing the geocode function locally to see if the actual geometry can be used instead of the bbox and there's an issue with the gdf being returning having a multipolygon geometry. This is the case for many coastal cities with islands e.g New York. Perhaps for now we stick with bbox and then look at other options in the future? Unless anyone has an idea now? |
…n exact geometry, add test for multipolygon geocoding result
hi @mtravis, sorry for the slow response. thanks for rigorous testing - good catch! i had a look and noticed it's failing in the if you're happy, i'll merge. |
Sorry for the slow response! I've been slammed lately, and I've never gotten a great system to properly filter important github messages. Don't have time to look in depth right now, but please do merge when ready! I'm excited to try it out. And I definitely think this is worthy of a release, I'll see if I might be able to pull that off in the next couple of days. |
Thanks both. @felix-schott I'm happy for you to merge so I've put into review. I'll take it for a test run tomorrow. Looking forward to getting this out there. |
Tried it out, looks good. I put in one bug #55 to make it a bit nicer, but I'll go ahead and merge and we can do that one later. |
I've added a new geocode function that takes a place name and provides a bbox well known text (WKT).
We could pass this to the sql function and add a geocode command negating the need to add any geojson.