There are many ways to retrieve the polygon information when you know that the information is already present somewhere (data locally or in database containing extracted info about polygon). But this question is to figure out, how do we retrieve a polygon info when you don't have any extracted info.
I found that using OpenStreetMaps (OSM), we could download the data containing all the info, so I downloaded the continent wise data from the below site.
Later I stored the information into Postgis using
Osm2pgsql. I am using postgis query plugins to select the information like polygon ID and other things. But how do I get the actual polygon geometry of a point containing lat/long of type=farmland.
SELECT Polygon_geom //random name FROM planet_osm_polygon WHERE boundary = 'farmland' AND AND ST_Intersects( ST_GeomFromText('POINT(-122.679 45.519)', 4326), ST_Transform(way, 4326) )
EDIT: I am looking for something specific like this as shown below, say I have a point on a farm and I don't know the boundary.
And using OSM (Planet-OSM) data, I get the boundary. But not what I expected (querying for landuse='farmland') doesnt return result in few cases. Does the Planet-OSM data contains the polygon info of all the farmland in specific? or it depends on the country wise data with only administrative boundaries? Is it the right way or is there any other alternate solutions?
NMScomment got the output from overpass as follows. But my main concern still remains unanswered. How do I get an individual polygon? Now I either get a polygon with more than 3 in a single polygon or nothing (maybe OSM considers them non-farmland). Do I need to filter my query further. Please correct me if I am going in a wrong direction.