Skip to content

Instantly share code, notes, and snippets.

@aaronschiff
Created February 11, 2016 20:45
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 aaronschiff/6bc41e383c8ca8376a15 to your computer and use it in GitHub Desktop.
Save aaronschiff/6bc41e383c8ca8376a15 to your computer and use it in GitHub Desktop.
Transformations on LINZ shapefiles for use in Mapbox
DATA_DIR = /Users/aaron/Google\ Drive/Data/Geographic/NZ/Topographic
nzlakes: nzlakes50.shp nzlakes250.shp nzlakes500.shp
nzlakes50.shp: $(DATA_DIR)/50k/nz-lake-polygons-topo-150k/nz-lake-polygons-topo-150k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/50k/nz-lake-polygons-topo-150k/nz-lake-polygons-topo-150k.shp -nln temp
ogr2ogr nzlakes50.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzlakes250.shp: $(DATA_DIR)/250k/nz-lake-polygons-topo-1250k/nz-lake-polygons-topo-1250k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/250k/nz-lake-polygons-topo-1250k/nz-lake-polygons-topo-1250k.shp -nln temp
ogr2ogr nzlakes250.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzlakes500.shp: $(DATA_DIR)/500k/nz-lake-polygons-topo-1500k/nz-lake-polygons-topo-1500k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/500k/nz-lake-polygons-topo-1500k/nz-lake-polygons-topo-1500k.shp -nln temp
ogr2ogr nzlakes500.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzrivers: nzrivers50.shp nzrivers250.shp nzrivers500.shp
nzrivers50.shp: $(DATA_DIR)/50k/nz-river-polygons-topo-150k/nz-river-polygons-topo-150k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/50k/nz-river-polygons-topo-150k/nz-river-polygons-topo-150k.shp -nln temp
ogr2ogr nzrivers50.shp temp.shp -sql "SELECT OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzrivers250.shp: $(DATA_DIR)/250k/nz-river-polygons-topo-1250k/nz-river-polygons-topo-1250k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/250k/nz-river-polygons-topo-1250k/nz-river-polygons-topo-1250k.shp -nln temp
ogr2ogr nzrivers250.shp temp.shp -sql "SELECT OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzrivers500.shp: $(DATA_DIR)/500k/nz-river-polygons-topo-1500k/nz-river-polygons-topo-1500k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/500k/nz-river-polygons-topo-1500k/nz-river-polygons-topo-1500k.shp -nln temp
ogr2ogr nzrivers500.shp temp.shp -sql "SELECT OGR_GEOM_AREA/1000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzcoast: nzcoast50.shp nzcoast250.shp nzcoast500.shp
nzcoast50.shp: $(DATA_DIR)/50k/nz-coastlines-and-islands-polygons-topo-150k/nz-coastlines-and-islands-polygons-topo-150k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/50k/nz-coastlines-and-islands-polygons-topo-150k/nz-coastlines-and-islands-polygons-topo-150k.shp -nln temp
ogr2ogr nzcoast50.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzcoast250.shp: $(DATA_DIR)/250k/nz-coastlines-and-islands-polygons-topo-1250k/nz-coastlines-and-islands-polygons-topo-1250k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/250k/nz-coastlines-and-islands-polygons-topo-1250k/nz-coastlines-and-islands-polygons-topo-1250k.shp -nln temp
ogr2ogr nzcoast250.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzcoast500.shp: $(DATA_DIR)/500k/nz-coastlines-and-islands-polygons-topo-1500k/nz-coastlines-and-islands-polygons-topo-1500k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/500k/nz-coastlines-and-islands-polygons-topo-1500k/nz-coastlines-and-islands-polygons-topo-1500k.shp -nln temp
ogr2ogr nzcoast500.shp temp.shp -sql "SELECT name, OGR_GEOM_AREA/1000000 as area FROM temp" -t_srs EPSG:4326
rm temp.*
nzgeonames: nzgeonames50.shp nzgeonames250.shp nzgeonames500.shp
nzgeonames50.shp: $(DATA_DIR)/50k/nz-geographic-names-topo-150k/nz-geographic-names-topo-150k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/50k/nz-geographic-names-topo-150k/nz-geographic-names-topo-150k.shp -nln temp
ogr2ogr nzgeonames50.shp temp.shp -sql "SELECT name, desc_code FROM temp" -t_srs EPSG:4326
rm temp.*
nzgeonames250.shp: $(DATA_DIR)/250k/nz-geographic-names-topo-1250k/nz-geographic-names-topo-1250k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/250k/nz-geographic-names-topo-1250k/nz-geographic-names-topo-1250k.shp -nln temp
ogr2ogr nzgeonames250.shp temp.shp -sql "SELECT name, desc_code FROM temp" -t_srs EPSG:4326
rm temp.*
nzgeonames500.shp: $(DATA_DIR)/500k/nz-geographic-names-topo-1500k/nz-geographic-names-topo-1500k.shp
rm -f temp.*
ogr2ogr temp.shp $(DATA_DIR)/500k/nz-geographic-names-topo-1500k/nz-geographic-names-topo-1500k.shp -nln temp
ogr2ogr nzgeonames500.shp temp.shp -sql "SELECT name, desc_code FROM temp" -t_srs EPSG:4326
rm temp.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment