Skip to content

Instantly share code, notes, and snippets.

@philvarner
Created September 25, 2018 17:24
Show Gist options
  • Save philvarner/821bcb097fc238b3309a26a43b16c7e7 to your computer and use it in GitHub Desktop.
Save philvarner/821bcb097fc238b3309a26a43b16c7e7 to your computer and use it in GitHub Desktop.
Use the GeoSWAK docker container and GDAL tools to create shapefile for a raster reprojection from sinusoidal to WGS84/EPSG:4326
#!/bin/bash
# extract the band as geotiff from the HDF source
docker run -v $(pwd):/data s22s/geo-swak gdal_translate 'HDF4_EOS:EOS_GRID:"MCD43A4.A2018220.h19v02.006.2018233203810.hdf":MOD_Grid_BRDF:Nadir_Reflectance_Band2' B02.tif
# reproject the geotiff in WGS84/EPSG:4326 so we can manually compare it to the geojson
docker run -v $(pwd):/data s22s/geo-swak gdalwarp -s_srs '+proj=sinu +R=6371007.181 +nadgrids=@null +wktext' -r lanczos -t_srs '+proj=longlat +datum=WGS84 +no_defs' B02.tif B02-wgs84.tif
# extract the shapefile from the sinusoidal geotiff
docker run -v $(pwd):/data s22s/geo-swak gdaltindex -tileindex location B02-extent.shp B02.tif
# reproject the shapefile to EPSG:4326 GeoJSON
docker run -v $(pwd):/data s22s/geo-swak ogr2ogr -segmentize 1000 -t_srs EPSG:4326 -lco WRITE_BBOX=YES B02-epsg4326.geojson B02-extent.shp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment