Hi All,
I would like to get some advice regarding which path I should take. Problem: Given a coordinate I want to know to which geographical object it belongs to. Path 1 Using Glorp to make a query to a Postgis instance containing the boundaries of the geobjects Path 2 Use the data form GADM data (according to this thread). I would avoid path 1 in order to avoid installation of postgi. From the thread mentioned above, I thing that it requires some development. Regarding Path 2, I don't see which framework or library should I use to import and query the data contained in the KMZ from GADM. Any advice is welcome. Best regards. Art |
Arturo,
In Pharo itself, you could just do it yourself, like this: T3GeoTools class>>#is: position inside: polygon "T3GeoTools is: 5.33732@50.92601 inside: { 5.48230@50.82249. 5.49523@50.81288. 5.50138@50.82008. 5.50228@50.82595. 5.49265@50.82560. 5.48230@50.82249 }" "T3GeoTools is: 5.49007@50.82205 inside: { 5.48230@50.82249. 5.49523@50.81288. 5.50138@50.82008. 5.50228@50.82595. 5.49265@50.82560. 5.48230@50.82249 }" "Point in polygon - ray casting algorithm - http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html" | inside otherIndex | inside := false. otherIndex := polygon size. polygon doWithIndex: [ :each :index | | other | other := polygon at: otherIndex. (((each y > position y) ~= (other y > position y)) and: [ position x < (((other x - each x) * (position y - each y) / (other y - each y)) + each x) ]) ifTrue: [ inside := inside not ]. otherIndex := index ]. ^ inside Inside circle, rectangle etc are trivial. Sven > On 25 Jul 2015, at 01:19, Arturo Zambrano <[hidden email]> wrote: > > Hi All, > I would like to get some advice regarding which path I should take. > > Problem: > Given a coordinate I want to know to which geographical object it belongs to. > > Path 1 > Using Glorp to make a query to a Postgis instance containing the boundaries of the geobjects > > > > Path 2 > Use the data form GADM data (according to this thread). > > > I would avoid path 1 in order to avoid installation of postgi. From the > thread mentioned above, I thing that it requires some development. > > > Regarding Path 2, I don't see which framework or library should I use to > import and query the data contained in the KMZ from GADM. > > > Any advice is welcome. > > Best regards. > Art > > |
In reply to this post by Arturo Zambrano
Hi Arturo, The GADM world tree is built from a CSV which I generated from the GADM 2.0 dBase files for the whole world. I checked the dBase format and doesn't include the polygon information you find in the .kmz files. I saw they released 2.5 this month (July 2015) but only in ESRI geodatabase format (which I didn't investigated yet, but not the same as ESRI shapefile format) and will release 2.7 in August 2015. Another way could be just to parse the KML (is just an XML file) using XPath or XMLPullParser. About locating the point in a polygon the problem of traditional 2D inclusion tests (ray crossing methods) is that require large storage, given polygons of enough size, complexity and amount of edges. This is a common situation with level 1 and 2 polygons. New methods for example classiffy polygon edges into layers, results in faster inclusion test. Hernán 2015-07-24 20:19 GMT-03:00 Arturo Zambrano <[hidden email]>:
|
In reply to this post by Sven Van Caekenberghe-2
Thanks Sven, I will test the performance... some my objects have around 10000 points. Maybe I will reduce the amount of point and sacrifice some precision. I thought something like that was already available in SH. Best regards On Sat, Jul 25, 2015 at 4:31 AM, Sven Van Caekenberghe <[hidden email]> wrote: Arturo, |
In reply to this post by hernanmd
Hi Hernán On Sat, Jul 25, 2015 at 4:54 AM, Hernán Morales Durand <[hidden email]> wrote:
Nope, just to count points for each different province.
Of course,thanks. I wanted to know if there were a library supporting KMZ, and doing some queries on the objects contained there. From your reply and Sven's , I see there is no such library, but it seems very easy to implement that functionality. My only concern now is performance, I will try it and let you know.
Thanks again. best regards art
|
Free forum by Nabble | Edit this page |