Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Last active September 26, 2016 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanfb/3f9d1afc4bf8e45b56dc9dbca6f2abc3 to your computer and use it in GitHub Desktop.
Save ryanfb/3f9d1afc4bf8e45b56dc9dbca6f2abc3 to your computer and use it in GitHub Desktop.
Quick-and-Dirty Filtering of Pleiades Places by Modern Country with GDAL ogr2ogr

In this tutorial, I'll give a quick way to filter Pleiades places to those contained within a modern country's borders.

Install GDAL with brew install gdal (on a Mac) or download GDAL binaries for your platform.

Download a modern country's shapefile (for this example, Bulgaria) from GADM: http://www.gadm.org/country

Download the latest Pleiades KMZ data dump. Unzip to KML with unzip pleiades-latest.kmz.

Use the top-level administrative boundary for Bulgaria to clip the resulting tmp/doc.kml file and save the result as GeoJSON:

ogr2ogr -f GeoJSON pleiades-bulgaria.json tmp/doc.kml -clipsrc BGR_adm0.shp

Result: pleiades-bulgaria.json

NB: these results may still have unlocated places (not in the modern country) due to the clipping algorithm used by GDAL.

Related reading:

Slower and Cleaner Method

This should filter out unlocated places.

  • wget http://atlantides.org/downloads/pleiades/json/pleiades-places-latest.json.gz

  • gunzip pleiades-places-latest.json.gz

  • Use pleiades-json-to-geojson to convert to geojson:

      ./pleiades-json-to-geojson.rb pleiades-places-latest.json > pleiades-places-latest.geojson
    
  • ogr2ogr -f GeoJSON pleiades-bulgaria.json pleiades-places-latest.geojson -clipsrc BGR_adm0.shp -sql "SELECT * FROM OGRGeoJSON WHERE location_precision != 'unlocated'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment