-
-
Save anonymous/ac9462bacf38c9b52b28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 22.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">GDAL/OGR Quickstart</span></h1></b>\n", | |
"\n", | |
"\n", | |
"\n", | |
"This Notebook is derived from the original [GDAL-OGR quickstart](../doc/en/quickstart/gdal_quickstart.html) adapted to run interactively in a IPython notebook and is devided in two parts **GDAL** (raster data) and **OGR** (vector data)\n", | |
"\n", | |
"<h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">GDAL</span></h1>\n", | |
"* Explore your image data with ```gdalinfo```\n", | |
"\n", | |
"* Format translations with ```gdal_translate```\n", | |
"* Reproject your data with gdalwarp\n", | |
"* Mosaic your data with ```gdal_warp``` or ```gdal_merge.py```\n", | |
"* Build a shapefile as a raster tileindex with ```gdaltindex```\n", | |
"\n", | |
"\n", | |
"<h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">OGR </span></h1>\n", | |
"* get information about your data with ```ogrinfo```\n", | |
"* use ```ogr2ogr``` to transform your data to other formats" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Get to know GDAL</span></h1></b> \n", | |
"\n", | |
"\n", | |
"You will find the demo data at ```/usr/local/share/data```. We want to have a look at the [naturalearth dataset](../doc/en/overview/naturalearth_overview.html) data in this quickstart. We want to work with a copy of the data. So the first step is to copy the data to your home directory." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"cd /home/user\n", | |
"cp -R /usr/local/share/data/natural_earth2/ ./gdal_natural_earth" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"You will then find a series of geotiff file:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"ls /home/user/gdal_natural_earth/HYP_50M_SR_W.*" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The web browser is not happy with tif files so to have a quick look at the image we convert it to a web friendly format (PNG) using the imagemagic utility ```convert``` (this requires few seconds)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"convert /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W.png" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"display < /home/user/gdal_natural_earth/HYP_50M_SR_W.png" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Get information about the raster data with <mark><i>gdalinfo</i></mark></span></h1></b> " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W.tif" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"---\n", | |
"\n", | |
"Note:\n", | |
"* Driver is “GTiff/GeoTIFF”\n", | |
"* Size is 10800x5400\n", | |
"* 3 Bands of type Byte.\n", | |
"* Coordinates\n", | |
"* Coordinate system is World Geodetic System 84" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Simple Format Translation</span></h1></b> " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"First get to know your drivers. The ```--formats``` commandline switch of gdalinfo can be used to see a list of available format drivers.\n", | |
"\n", | |
"Each format reports if it is:\n", | |
"* read only (ro),\n", | |
"* read/write (rw) or\n", | |
"* read/write/update (rw+)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo --formats" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo --format GTiff " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Translation</span></h1></b> \n", | |
"\n", | |
"Translations are accomplished with the gdal_translate command. The default output format is GeoTIFF. The ```-of``` flag is used to select an output format and the ```-co``` flag is used to specify a creation option:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -of JPEG -co QUALITY=10 /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W.jpg" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"display < /home/user/gdal_natural_earth/HYP_50M_SR_W.jpg" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The -ot switch can be used to alter the output data type." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -ot Int16 /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W_Int16.tif" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Use gdalinfo to verify data type." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W.tif | grep Band" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W_Int16.tif | grep Band" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Resizing</span></h1></b> \n", | |
"\n", | |
"The -outsize switch can be used to set the size of the output file." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -outsize 50% 50% /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W_small.tif" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Use gdalinfo to verify the size." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W.tif | grep Size" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W_small.tif | grep Size" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Rescaling</span></h1></b> " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The -scale switch can be used to rescale the data range of a given image. Explicit control of the input and output ranges is also available. The gdalinfo ```-mm``` switch can be used to see pixel min/max values.\n", | |
"\n", | |
"The output will display a computed Min/Max value for each band in the raster imput (3 band in our case)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo -mm /home/user/gdal_natural_earth/HYP_50M_SR_W_small.tif | grep Min/Max" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"To rescale a specific band we can use the \"-scale_bn\" syntax where bn is a band number (e.g. \"-scale_2\" for the 2nd band of the output dataset), in the example below we will rescale the 3 bands of the HYP_50M_SR_W GeoTiff to be in the range 0-255 :" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -scale_1 62.000 255.000 0 255.000 \\\n", | |
" -scale_2 85.000 255.000 0 255.000 \\\n", | |
" -scale_3 79.000 255.000 0 255.000 \\\n", | |
" /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W_scaled.tif" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Check the results with ```gdalinfo``` :" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdalinfo -mm /home/user/gdal_natural_earth/HYP_50M_SR_W_scaled.tif | grep Min/Max" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Let's convert the scaled output to JPG for a quick display, notice the color rearrangement." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -of JPEG -co QUALITY=40 /home/user/gdal_natural_earth/HYP_50M_SR_W_scaled.tif /home/user/gdal_natural_earth/HYP_50M_SR_W_scaled.jpg" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"display < /home/user/gdal_natural_earth/HYP_50M_SR_W_scaled.jpg" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Splitting</span></h1></b> " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Let’s split our image into two with ```-srcwin``` which makes a copy based on pixel/line location (xoff yoff xsize ysize). You also could use ```-projwin``` and define the corners in georeferenced coordinates (ulx uly lrx lry)." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -srcwin 0 0 5400 5400 /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/west.tif\n", | |
"gdal_translate -srcwin 5400 0 5400 5400 /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/east.tif" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdal_translate -of JPEG -co QUALITY=40 /home/user/gdal_natural_earth/east.tif /home/user/gdal_natural_earth/east.jpg\n", | |
"gdal_translate -of JPEG -co QUALITY=40 /home/user/gdal_natural_earth/west.tif /home/user/gdal_natural_earth/west.jpg" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Raster tileindex with gdaltindex</span></h1></b> \n", | |
"\n", | |
"\n", | |
"You can build a shapefile as a raster tileindex. For every image a polygon is generated with the bounds of the extent of the polygon and the path to the file." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"gdaltindex /home/user/gdal_natural_earth/index_natural_earth.shp /home/user/gdal_natural_earth/*st.tif" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The command above just created a new ESRI Shape File (default vector format), we will see how to work on vector files later on in the **OGR** section." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">Reprojecting</span></h1></b> \n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"For this process we assume that HYP_50M_SR_W.tif has been properly created with bounds. As we saw before with gdalinfo HYP_50M_SR_W has a proper coordinate system set. \n", | |
"\n", | |
"If the tif file we want work on doesn't have proper projection information (wich is the case in most *.tif* files when associated with a world file *.tfw*) it is possible to assign a coordinate system to the image with ```gdal_translate``` and the flag ```-a_srs``` e.g :\n", | |
"\n", | |
" gdal_translate -a_srs WGS84 HYP_50M_SR_W.tif HYP_50M_SR_W_4326.tif\n", | |
" \n", | |
" \n", | |
"Given a proper georeferenced raster file the ```gdalwarp``` command can be used to assign a new Spatiale Reference System to it. Here we reproject the WGS84 geographic image to the Mercator projection:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Creating output file that is 7292P x 9625L.\r\n", | |
"Processing input file /home/user/gdal_natural_earth/HYP_50M_SR_W.tif.\r\n", | |
"0...10...20...30...40...50...60...70...80...90...100 - done.\r\n" | |
] | |
} | |
], | |
"source": [ | |
"gdalwarp -t_srs '+proj=merc +datum=WGS84' /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/mercator.tif" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0\r\n" | |
] | |
} | |
], | |
"source": [ | |
"convert /home/user/gdal_natural_earth/mercator.tif /home/user/gdal_natural_earth/mercator.png" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"display < /home/user/gdal_natural_earth/mercator.png" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"<b><h1 style=\"margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.4px; font: 18.0px 'Lucida Sans'; color: #004d87; -webkit-text-stroke: #004d87; background-color: #ffffff\"><span class=\"s1\">OGR</span></h1></b> \n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Like we did with raster using ```gdalinfo```, is possible to retrieve descriptive information from a vector datasource using the command line too ```ogrinfo```.\n", | |
"Let's run ```ogrinfo``` on the previously generated shapefile ```index_natural_earth.shp```:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"INFO: Open of `/home/user/gdal_natural_earth/index_natural_earth.shp'\r\n", | |
" using driver `ESRI Shapefile' successful.\r\n", | |
"\r\n", | |
"Layer name: index_natural_earth\r\n", | |
"Geometry: Polygon\r\n", | |
"Feature Count: 2\r\n", | |
"Extent: (-180.000000, -90.000000) - (180.000000, 90.000000)\r\n", | |
"Layer SRS WKT:\r\n", | |
"GEOGCS[\"GCS_WGS_1984\",\r\n", | |
" DATUM[\"WGS_1984\",\r\n", | |
" SPHEROID[\"WGS_84\",6378137,298.257223563]],\r\n", | |
" PRIMEM[\"Greenwich\",0],\r\n", | |
" UNIT[\"Degree\",0.017453292519943295]]\r\n", | |
"location: String (254.0)\r\n", | |
"OGRFeature(index_natural_earth):0\r\n", | |
" location (String) = /home/user/gdal_natural_earth/east.tif\r\n", | |
" POLYGON ((-0.00000000001796 90.0,179.999999999964047 90.0,179.999999999964047 -89.999999999982009,-0.00000000001796 -89.999999999982009,-0.00000000001796 90.0))\r\n", | |
"\r\n", | |
"OGRFeature(index_natural_earth):1\r\n", | |
" location (String) = /home/user/gdal_natural_earth/west.tif\r\n", | |
" POLYGON ((-180.0 90.0,-0.00000000001796 90.0,-0.00000000001796 -89.999999999982009,-180.0 -89.999999999982009,-180.0 90.0))\r\n", | |
"\r\n" | |
] | |
} | |
], | |
"source": [ | |
"ogrinfo /home/user/gdal_natural_earth/index_natural_earth.shp index_natural_earth" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"The shape file we just created can not be rendered directly in the notebook. Later in the python tutorial we'll learn how to use libraries like *shapely* to render directly vector data. \n", | |
"For now to display the results of our processing in the notebook we'll use the ```shp2img``` command line tool (provided by *[mapserver](../doc/en/overview/mapserver_overview.html)* ).\n", | |
"```shp2img``` require a *mapserver mapfile* as input to generate a rendered image.\n", | |
"Below we'll write a mapfile with 3 layers :\n", | |
"* west.tif\n", | |
"* east.tif\n", | |
"* index_natural_earth.shp\n", | |
"Note: the shapefile color has been classified based on the shapefile attribute ```location``` with a translarency to show the 2 raster images underneat." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"echo 'MAP\n", | |
" EXTENT -180 -89.999999999982 179.999999999964 90\n", | |
" IMAGETYPE \"png\"\n", | |
" NAME \"simplepolygon\"\n", | |
" SIZE 600 600\n", | |
" STATUS ON\n", | |
" UNITS DD\n", | |
"\n", | |
" OUTPUTFORMAT\n", | |
" NAME \"png\"\n", | |
" MIMETYPE \"image/png\"\n", | |
" DRIVER \"AGG/PNG\"\n", | |
" EXTENSION \"png\"\n", | |
" IMAGEMODE RGB\n", | |
" TRANSPARENT TRUE\n", | |
" END # OUTPUTFORMAT\n", | |
"\n", | |
" PROJECTION\n", | |
" \"proj=longlat\"\n", | |
" \"datum=WGS84\"\n", | |
" \"no_defs\"\n", | |
" END # PROJECTION\n", | |
"\n", | |
" LAYER\n", | |
" DATA \"/home/user/gdal_natural_earth/west.tif\"\n", | |
" EXTENT -180 -89.999999999982 -1.79596892913025e-11 90\n", | |
" METADATA\n", | |
" \"ows_title\"\t\"west\"\n", | |
" END # METADATA\n", | |
" NAME \"west\"\n", | |
" PROJECTION\n", | |
" \"proj=longlat\"\n", | |
" \"datum=WGS84\"\n", | |
" \"no_defs\"\n", | |
" END # PROJECTION\n", | |
" STATUS ON\n", | |
" TILEITEM \"location\"\n", | |
" TYPE RASTER\n", | |
" UNITS METERS\n", | |
" END # LAYER\n", | |
"\n", | |
" LAYER\n", | |
" DATA \"/home/user/gdal_natural_earth/east.tif\"\n", | |
" EXTENT -1.79596892913025e-11 -89.999999999982 179.999999999964 90\n", | |
" METADATA\n", | |
" \"ows_title\"\t\"east\"\n", | |
" END # METADATA\n", | |
" NAME \"east\"\n", | |
" PROJECTION\n", | |
" \"proj=longlat\"\n", | |
" \"datum=WGS84\"\n", | |
" \"no_defs\"\n", | |
" END # PROJECTION\n", | |
" STATUS ON\n", | |
" TILEITEM \"location\"\n", | |
" TYPE RASTER\n", | |
" UNITS METERS\n", | |
" END # LAYER\n", | |
" \n", | |
" LAYER\n", | |
" DATA \"/home/user/gdal_natural_earth/index_natural_earth.shp\"\n", | |
" EXTENT -180 -89.999999999982 179.999999999964 90\n", | |
" NAME \"index_natural_earth\"\n", | |
" PROJECTION\n", | |
" \"proj=longlat\"\n", | |
" \"datum=WGS84\"\n", | |
" \"no_defs\"\n", | |
" END # PROJECTION\n", | |
" STATUS ON\n", | |
" TILEITEM \"location\"\n", | |
" TYPE POLYGON\n", | |
" UNITS METERS\n", | |
" CLASS\n", | |
" NAME \"/home/user/gdal_natural_earth/east.tif\"\n", | |
" EXPRESSION (\"[location]\" =\"/home/user/gdal_natural_earth/east.tif\")\n", | |
" STYLE\n", | |
" OPACITY 50\n", | |
" COLOR 218 57 57\n", | |
" END # STYLE\n", | |
" STYLE\n", | |
" OUTLINECOLOR 0 0 0\n", | |
" WIDTH 0.26\n", | |
" END # STYLE\n", | |
" END # CLASS\n", | |
" CLASS\n", | |
" NAME \"/home/user/gdal_natural_earth/west.tif\"\n", | |
" EXPRESSION (\"[location]\" =\"/home/user/gdal_natural_earth/west.tif\")\n", | |
" STYLE\n", | |
" OPACITY 50\n", | |
" COLOR 18 211 14\n", | |
" END # STYLE\n", | |
" STYLE\n", | |
" OUTLINECOLOR 0 0 0\n", | |
" WIDTH 0.26\n", | |
" END # STYLE\n", | |
" END # CLASS\n", | |
" END # LAYER\n", | |
" \n", | |
"END # MAP' > index_natural_earth.map" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"shp2img -m index_natural_earth.map -i PNG -o index_natural_earth.png" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"display < index_natural_earth.png" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"#gdalwarp -t_srs EPSG:4326 -te -180.0000000 -90.0000000 180.0000000 90.0000000 /home/user/gdal_natural_earth/HYP_50M_SR_W.tif /home/user/gdal_natural_earth/HYP_50M_SR_W_geo.tif" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"#gdalinfo /home/user/gdal_natural_earth/HYP_50M_SR_W_geo.tif" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Bash", | |
"language": "bash", | |
"name": "bash" | |
}, | |
"language_info": { | |
"codemirror_mode": "shell", | |
"file_extension": ".sh", | |
"mimetype": "text/x-sh", | |
"name": "bash" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment