Geospatial

Natural Earth

Shapefiles

  • How to get information about a shapefile

    ogrinfo -so -al AREA.shp
    
  • How to clip Shapefile with Shapefile

    ogr2ogr -clipsrc CLIP.shp OUTPUT.shp INPUT.shp
    
  • How to convert a Shapefile to GeoJSON

    ogr2ogr -f GeoJSON OUTPUT.geojson INPUT.shp
    
  • How to reproject a Shapefile

    ogr2ogr -t_srs EPSG:2784 OUTPUT.shp INPUT.shp
    

GeoJSON

  • What is the minimum valid GeoJSON object?

    {
      "type": "FeatureCollection",
      "features": []
    }
    
  • How to convert GeoJSON to TopoJSON

    geo2topo INPUT.geojson > OUTPUT.topojson
    

Rasters

  • How to get information about a GeoTIFF

    gdalinfo AREA.tiff
    
  • How to convert a GeoJPEG to a GeoTIFF

    gdal_translate -of GTiff -a_srs EPSG:27700 INPUT.jpg OUTPUT.tiff
    
  • How to convert a GeoTIFF to a GeoJPEG

    gdal_translate -of JPEG -scale -co worldfile=yes INPUT.tiff OUTPUT.jpg
    

OpenStreetMap

  • Website

  • How to clip OpenStreetMap data with a GeoJSON boundary

    osmium extract -p BOUNDARY.geojson INPUT.osm.pbf -o OUTPUT.pbf
    
  • How to import an OpenStreetMap PBF file into a PostGIS database

    The PostGIS database must have the HStore extension.

    osm2pgsql -d DATABASE_NAME -c FILENAME.pbf