Python GeoModel Alternative

I am looking for an alternative library for the application data warehouse that will execute geocodes with the nearest n or boxes, I currently use GeoModel 0.2 and it works quite slowly (in some cases โ†’ 1.5s). Anyone have any suggestions?

Thanks!

+6
python google-app-engine gis google-cloud-datastore geohashing
source share
3 answers

I have the same problem with a geomodel. For this, I use resolution 4, and I use python sort and filter.

SEARCHED_LOCATION = db.GeoPt("48.8566667, 2.3509871") # Location of Paris. DISTANCE = 50000 #Between 10000 and 150000. MAX_RESULTS = 300 # Resolution '4' is about 150 kilometers i suppose it a good compromise. bbox = geocell.compute_box(geocell.compute(SEARCHED_LOCATION, resolution=4)) cell = geocell.best_bbox_search_cells(bbox, geomodel.default_cost_function) query.filter('location_geocells IN', cell) # Python filters def _func(x): """Private method used to set the distance of the model to the searched location and return this distance. """ x.dist = geomath.distance(SEARCHED_LOCATION, x.location) return x.dist results = sorted(query.fetch(MAX_RESULTS), key=_func) # Order the result by distance results = [x for x in results if x.dist <= DISTANCE] # Filter the result 
+6
source share

Instead of using the geomodel version 0.2.0, use the withasync branch (see

http://code.google.com/p/geomodel/source/browse/#svn/branches/withasync ). This will allow you to run queries in parallel using asynctools, which will be significantly faster for many queries.

Make sure you have asynctools in your application / pythonpath.

+4
source share

I canโ€™t point you to an existing library that has better performance, but as I recall, GeoModel is open source, and the code is not difficult to understand. We found that we could improve some of the improvements by adjusting the code according to our scenario.

For example, if you donโ€™t need the closest -n, you just need X-results from a specific bounding box or radius, maybe you can improve the speed of GeoModel, since GeoModel should currently get each record in the corresponding geohash and then sort for closest in memory. (The details of this implementation are left as an exercise for the reader.)

You might also consider setting up the number of geohash usage levels. If you have a lot of dense data and request small areas, you can significantly increase performance by saving 16 levels instead of 8 or 12.

(I donโ€™t look at the source of GeoModel now, but I remember when I last used it a few months ago, so take it with salt and dive into the source code yourself.)

+2
source share

All Articles