3

I'm aware that there are several similar questions already but I have been searching for days and not been able to solve my problem:

All solutions I've found require GDAL, which I have not been able to install (even doing all the environment variables tweaking etc.) except by using OSGEO4W, which allows me to use osgeo, but only in its own shell, rather than in the shell I use for everything else.

I have the country shapefiles, I have the shapely package. Is there a way to do this without GDAL? (or as an alternative, an easy way to get GDAL packages in my own shell?)

  • Can you please edit your post to a single question? What do you prefer: installing/importing GDAL or intersecting country shapefiles with GPS coordinates without using GDAL? – Kersten Oct 20 '15 at 13:36
  • Study OSGeo4W.bat and see how it sets paths and some environment parameters. That is a bit tricky because the first batch file is calling a bunch of other ones but you can also check the end result with "PATH" and "SET" from your OSGeo4W shell. Then set the same things in your own shell. – user30184 Oct 20 '15 at 13:42
  • @Kersten, I have a preference for not using GDAL, but either way would be a big relief. – Alexis Eggermont Oct 20 '15 at 13:57
6

I finally found what I was looking for: a package called reverse_geocode. It can be installed with pip.

>>>> import reverse_geocode 
>>>> coordinates = (-37.81, 144.96), (31.76, 35.21)
>>>> reverse_geocode.search(coordinates)
[{'city': 'Melbourne', 'code': 'AU', 'country': 'Australia'},
 {'city': 'Jerusalem', 'code': 'IL', 'country': 'Israel'}]
0

you can user shp2pgsql to convert shape file to PostgreSQL table

example :shp2pgsql -a -s 4326 -D \"#{shapeFileName}\" #{tableName} | psql -h #{host} -U #{username} #{database}

This will create postgresTable which would have a geometry column and other columns such as name of county, etc. So each polygon is store as different row.

you can query using http://postgis.net/docs/manual-1.4/ST_Contains.html to check if point is present in polygon and fetch all the rows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.