User Tools

Site Tools


wiki:gdalpktools_kenya

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:gdalpktools_kenya [2019/11/14 18:17]
127.0.0.1 external edit
wiki:gdalpktools_kenya [2020/07/17 06:39] (current)
Line 6: Line 6:
 On **Linux or Mac**: On **Linux or Mac**:
   ​   ​
-  wget -N http://​www.spatial-ecology.net/​ost4sem/​exercise/​hydromatics-workshop.key+  wget -N http://​www.spatial-ecology.net/​ost4sem/​exercise/​id_rsa_class  ​-O id_rsa_class
   # Mac user can use this   # Mac user can use this
-  # curl -o hydromatics-workshop.key ​  http://​www.spatial-ecology.net/​ost4sem/​exercise/​hydromatics-workshop.key +  # curl -o id_rsa_class ​  http://​www.spatial-ecology.net/​ost4sem/​exercise/​id_rsa_class 
-  chmod 600 hydromatics-workshop.key+  chmod 600 id_rsa_class
   # login using the ssh. Change user???? in accordance to your user ID    # login using the ssh. Change user???? in accordance to your user ID 
-  ssh -i hydromatics-workshop.key ​user?????@hydromatics-workshop.cuahsi.org +  ssh -i  ​id_rsa_class ​-X -Y user??@52.138.103.28 
  
  
 On **Windows**:​\\ On **Windows**:​\\
  
-Download [[ https://​www.puttygen.com/​ | PuTTYgen ]] - copy the key in a text file and save as hydromatics-workshop.key ​- and import the [[  http://​www.spatial-ecology.net/​ost4sem/​exercise/​hydromatics-workshop.key ​hydromatics-workshop.key ​]] file.\\ +Download [[ https://​www.puttygen.com/​ | PuTTYgen ]] - copy the key in a text file and save as id_rsa_class ​- and import the [[  http://​www.spatial-ecology.net/​ost4sem/​exercise/​id_rsa_class ​id_rsa_class ​]] file.\\ 
-Use [[ https://​putty.org | PuTTY ]]  to ssh to user???@hydromatics-workshop.cuahsi.org.+Use [[ https://​putty.org | PuTTY ]]  to ssh to uuser??@52.138.103.28.
  
 ==== In the Ubuntu VM ==== ==== In the Ubuntu VM ====
 Data Directory: $HOME/​ost4sem/​exercise/​geodata\_SDM/​ \\ Data Directory: $HOME/​ost4sem/​exercise/​geodata\_SDM/​ \\
  
-  ##### download ​the data +  ##### Download ​the data ONLY if your following the exercise in your machine.  
 +  ##### I you are using the Linux Virtuan Machine you do not need to dowload the data. 
   mkdir -p $HOME/​ost4sem/​exercise   mkdir -p $HOME/​ost4sem/​exercise
   cd $HOME/​ost4sem/​exercise   cd $HOME/​ost4sem/​exercise
Line 29: Line 30:
   cd $HOME/​ost4sem/​exercise/​geodata_SDM   cd $HOME/​ost4sem/​exercise/​geodata_SDM
   wget -N http://​spatial-ecology.net/​ost4sem/​exercise/​geodata_SDM/​gdal-ogr-pktools.sh   wget -N http://​spatial-ecology.net/​ost4sem/​exercise/​geodata_SDM/​gdal-ogr-pktools.sh
-  ​rstudio ​$HOME/​ost4sem/​exercise/​geodata_SDM/​gdal-ogr-pktools.sh ​& +  ​emacs -nw  ​$HOME/​ost4sem/​exercise/​geodata_SDM/​gdal-ogr-pktools.sh 
-  ​+  ​## gedit $HOME/​ost4sem/​exercise/​geodata_SDM/​gdal-ogr-pktools.sh &
  
-Install PKTOOLS ​ 
-  sudo apt install pktools ​ 
-  ​ 
 ===== GDAL Commands ===== ===== GDAL Commands =====
  
Line 46: Line 44:
 # Visualize the image # Visualize the image
  
-qgis vegetation/​ETmean08-11.tif 
 openev vegetation/​ETmean08-11.tif openev vegetation/​ETmean08-11.tif
 </​code>​ </​code>​
Line 170: Line 167:
 gdalbuildvrt -overwrite vegetation/​ETmosaic.vrt vegetation/​stack_UL.tif vegetation/​stack_UR.tif vegetation/​stack_LL.tif vegetation/​stack_LR.tif gdalbuildvrt -overwrite vegetation/​ETmosaic.vrt vegetation/​stack_UL.tif vegetation/​stack_UR.tif vegetation/​stack_LL.tif vegetation/​stack_LR.tif
 gdal_translate -co COMPRESS=DEFLATE -co ZLEVEL=9 vegetation/​ETmosaic.vrt vegetation/​ETmosaic.tif gdal_translate -co COMPRESS=DEFLATE -co ZLEVEL=9 vegetation/​ETmosaic.vrt vegetation/​ETmosaic.tif
 +</​code>​
 +
 +=== Create shp border tiles  ===
 +<code bash>
 +rm -f vegetation/​tiles.*
 +gdaltindex ​ vegetation/​tiles.shp ​ vegetation/​stack_??​.tif
 </​code>​ </​code>​
  
Line 209: Line 212:
 ogrinfo -al -geom=NO ​  ​shp/​TM_WORLD_BORDERS.shp ogrinfo -al -geom=NO ​  ​shp/​TM_WORLD_BORDERS.shp
 # base on an attribute # base on an attribute
 +rm -f shp/​TM_UGANDA_BORDERS-0.3.*
 ogr2ogr ​ -overwrite ​ -f "ESRI Shapefile" ​ -where "NAME = '​Uganda'"​ shp/​TM_UGANDA_BORDERS-0.3.shp shp/​TM_WORLD_BORDERS.shp ogr2ogr ​ -overwrite ​ -f "ESRI Shapefile" ​ -where "NAME = '​Uganda'"​ shp/​TM_UGANDA_BORDERS-0.3.shp shp/​TM_WORLD_BORDERS.shp
  
 # base on dimension of the polygons # base on dimension of the polygons
 +rm -f shp/​TM_LARGE_BORDERS.*
 ogr2ogr ​ -overwrite ​ -f "ESRI Shapefile"​ -sql "​SELECT * FROM TM_WORLD_BORDERS WHERE OGR_GEOM_AREA > 100 " shp/​TM_LARGE_BORDERS.shp shp/​TM_WORLD_BORDERS.shp ogr2ogr ​ -overwrite ​ -f "ESRI Shapefile"​ -sql "​SELECT * FROM TM_WORLD_BORDERS WHERE OGR_GEOM_AREA > 100 " shp/​TM_LARGE_BORDERS.shp shp/​TM_WORLD_BORDERS.shp
 +</​code>​
 +
 +=== Add attribute and calculate a new value === 
 +
 +<code bash>
 +rm -f shp/​TM_WORLD_BORDERS_Area100.shp
 +ogr2ogr ​ shp/​TM_WORLD_BORDERS_Area100.shp shp/​TM_WORLD_BORDERS.shp
 +
 +ogrinfo -sql "ALTER TABLE TM_WORLD_BORDERS_Area100 ADD COLUMN Area100 real(12,​0)"​ shp/​TM_WORLD_BORDERS_Area100.shp
 +
 +ogrinfo ​ -dialect SQLite -sql "​UPDATE TM_WORLD_BORDERS_Area100 set Area100 = AREA + 10 " shp/​TM_WORLD_BORDERS_Area100.shp ​
 </​code>​ </​code>​
  
Line 260: Line 276:
 pkcomposite $(for file in LST/​LST_MOYDmax_month??​.tif LST/​LST_MOYDmax_month?​.tif ​ ; do echo -i $file ;  done ) -m LST/​LST_MOYDmax_month1-msk.tif -msknodata 0 -cr stdev   ​-dstnodata -1 -co  COMPRESS=LZW -co ZLEVEL=9 -o LST/​LST_MOYDmax_monthStdev.tif pkcomposite $(for file in LST/​LST_MOYDmax_month??​.tif LST/​LST_MOYDmax_month?​.tif ​ ; do echo -i $file ;  done ) -m LST/​LST_MOYDmax_month1-msk.tif -msknodata 0 -cr stdev   ​-dstnodata -1 -co  COMPRESS=LZW -co ZLEVEL=9 -o LST/​LST_MOYDmax_monthStdev.tif
 </​code>​ </​code>​
 +Pkcomposite is very flexible, it can deal with different extents, resolutions,​ and can be used in combination with gdal comand to make composite of modis immages (see [[ wiki:​modiswget | Download MODIS Land Surface Temperature (*.hdf) from Nasa ftp ]])
  
-an alternative way is to use pkstatprofile+An alternative way is to use pkstatprofile
  
 <code bash> <code bash>
Line 297: Line 314:
  
 <code bash> <code bash>
-rm -f shp/​polygons_stat.sqlite+rm -f shp/​polygons_stat.*
 pkextractogr -srcnodata -339999995214436424907732413799364296704 ​  -r mean -r stdev -r min    -i vegetation/​GPPmean08-11.tif -s  shp/​polygons.sqlite ​   -o   ​shp/​polygons_stat.sqlite pkextractogr -srcnodata -339999995214436424907732413799364296704 ​  -r mean -r stdev -r min    -i vegetation/​GPPmean08-11.tif -s  shp/​polygons.sqlite ​   -o   ​shp/​polygons_stat.sqlite
 +
 +pkextractogr -f "ESRI Shapefile"​ -srcnodata -339999995214436424907732413799364296704 ​  -r mean -r stdev -r min -i vegetation/​GPPmean08-11.tif -s  shp/​polygons.sqlite -o   ​shp/​polygons_stat.shp
  
 # we can also create a csv that can be manipulate later on with awk # we can also create a csv that can be manipulate later on with awk
Line 315: Line 334:
 pkextractogr -f CSV -buf 2 -srcnodata -339999995214436424907732413799364296704 -r mean -r stdev -r min -i vegetation/​GPPmean08-11.tif -s shp/​presence.shp -o shp/​point-buf_stat.csv pkextractogr -f CSV -buf 2 -srcnodata -339999995214436424907732413799364296704 -r mean -r stdev -r min -i vegetation/​GPPmean08-11.tif -s shp/​presence.shp -o shp/​point-buf_stat.csv
 </​code>​ </​code>​
 +
 +Remove all the output
 +
 +<code bash>
 +rm -f  vegetation/​GPPcv08-11.tif LST/​*_crop.tif vegetation/​ETmean08-11_crop_trh.tif vegetation/​ETmean08-11_crop_trh.txt vegetation/​ETmean08-11_crop.txt vegetation/​ETmosaic.vrt vegetation/​ETmosaic.tif ​ vegetation/​stack_UL.tif vegetation/​stack_UR.tif vegetation/​stack_LL.tif vegetation/​stack_LR.tif vegetation/​stack.vrt vegetation/​tiles.* vegetation/​ETmean08-11_crop_proximity.tif vegetation/​ETmean08-11_crop_buffer.tif ​ dem/​slope.tif dem/​aspect.tif ​ dem/tri.tif dem/tpi.tif dem/​roughness.tif vegetation/​ETmean08-11_01_trh?​.tif LST/​LST_MOYDmax_month1-msk.tif LST/​LST_MOYDmax_monthStdev.tif LST/​LST_MOYDmax_monthMean.tif ​ LST/​LST_MOYDmax_month_mean_stdev.tif LST/​LST_MOYDmax_month.vrt LST/​LST_MOYDmax_monthMean_aggreate10mean.tif LST/​LST_MOYDmax_monthMean_circular11mean.tif ​ temperature/​reclass_ug_bio_3.tif temperature/​reclass_ug_bio_3.txt shp/​polygons_stat.csv shp/​polygons_stat.* shp/​TM_WORLD_BORDERS_Area100.*
 +</​code>​
 +
 +
 +
 +
  
wiki/gdalpktools_kenya.1573755472.txt.gz · Last modified: 2020/07/17 06:40 (external edit)