├── calc_2021Feb ├── add_stream │ ├── src │ │ ├── nohup.out │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ └── wrte_ctl_5deg.f90 │ ├── tmp.sh │ ├── auto.sh │ ├── s00-link.sh │ ├── s05-rasterlize.sh │ ├── s01-extract_water.sh │ ├── t05-gdal.sh │ ├── s02-divide_lons.sh │ ├── s04-osm2shp.sh │ └── s03-divide_lonlat.sh ├── extract_water │ ├── auto.sh │ ├── s00-link.sh │ ├── u05-merge_planet.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── check_type.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ ├── set_bounds.f90 │ │ ├── wrte_ctl_5deg.f90 │ │ ├── add_lake.f90 │ │ └── check_relation.f90 │ ├── a02-waterlayer.sh │ ├── s05-rasterlize.sh │ ├── a01-preset.sh │ ├── u02-tag_relations.sh │ ├── u04-extract-id.sh │ ├── u03-ways.sh │ ├── t05-gdal.sh │ ├── s04-osm2shp.sh │ ├── s02-divide_lons.sh │ ├── u01-notag_relations.sh │ ├── s01-extract_water.sh │ └── s03-divide_lonlat.sh ├── add_canal │ ├── tmp.sh │ ├── auto.sh │ ├── s00-link.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ └── wrte_ctl_5deg.f90 │ ├── s05-rasterlize.sh │ ├── s01-extract_water.sh │ ├── t05-gdal.sh │ ├── s04-osm2shp.sh │ ├── s02-divide_lons.sh │ └── s03-divide_lonlat.sh ├── add_river │ ├── tmp.sh │ ├── auto.sh │ ├── s00-link.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ └── wrte_ctl_5deg.f90 │ ├── s05-rasterlize.sh │ ├── s01-extract_water.sh │ ├── t05-gdal.sh │ ├── s04-osm2shp.sh │ ├── s02-divide_lons.sh │ └── s03-divide_lonlat.sh ├── merge_water │ ├── Figure │ │ ├── VisualizationMemo.docx │ │ ├── readme.md │ │ ├── src │ │ │ ├── Makefile │ │ │ ├── set_name.f90 │ │ │ └── conv_form.f90 │ │ ├── t04-draw.sh │ │ ├── s04-jpg.sh │ │ └── draw.py │ ├── auto.sh │ ├── memo_class.md │ ├── src │ │ ├── Makefile │ │ ├── set_name.f90 │ │ ├── wrte_ctl_5deg.f90 │ │ ├── wrte_hdr_int1.f90 │ │ └── merge_mask.f90 │ ├── s02-add_hdr.sh │ ├── s01-merge_raster.sh │ └── s03-gdal.sh └── ReadMe.md ├── .gitignore ├── hires_2021Feb ├── extract_water │ ├── auto.sh │ ├── t02-upscale.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ ├── wrte_ctl_30m.f90 │ │ ├── wrte_ctl_10m.f90 │ │ └── upscale_1sec.f90 │ ├── s02-upscale.sh │ ├── s01-rasterlize.sh │ └── t01-gdal.sh ├── merge_water │ ├── auto.sh │ ├── src │ │ ├── Makefile │ │ ├── set_name.f90 │ │ ├── wrte_ctl_30m.f90 │ │ ├── wrte_ctl_10m.f90 │ │ ├── merge_mask.f90 │ │ └── upscale_1sec.f90 │ ├── s01-merge_raster.sh │ └── s02-upscale.sh ├── add_canal │ ├── auto.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ ├── wrte_ctl_30m.f90 │ │ ├── wrte_ctl_10m.f90 │ │ └── upscale_1sec.f90 │ ├── s01-rasterlize.sh │ └── t01-gdal.sh ├── add_stream │ ├── auto.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── set_name.f90 │ │ ├── marge_tmpfile.f90 │ │ ├── wrte_ctl_30m.f90 │ │ ├── wrte_ctl_10m.f90 │ │ └── upscale_1sec.f90 │ ├── s01-rasterlize.sh │ └── t01-gdal.sh ├── add_river │ ├── auto.sh │ ├── src │ │ ├── Makefile │ │ ├── set_window.f90 │ │ ├── check_type.f90 │ │ ├── set_name.f90 │ │ ├── set_bounds.f90 │ │ ├── marge_tmpfile.f90 │ │ ├── wrte_ctl_30m.f90 │ │ ├── wrte_ctl_10m.f90 │ │ ├── add_lake.f90 │ │ ├── check_relation.f90 │ │ └── upscale_1sec.f90 │ ├── s01-rasterlize.sh │ └── t01-gdal.sh └── ReadMe.md ├── OSM_sea ├── auto.sh ├── s00-link.sh ├── src │ ├── Makefile │ ├── set_window_1sec.f90 │ ├── set_window.f90 │ ├── set_name.f90 │ └── wrte_ctl_5deg.f90 ├── t02-1sec_gdal.sh ├── t01-auto_gdal.sh ├── s01-auto_conv.sh ├── s02-conv_1sec.sh └── ReadMe.md ├── distribute ├── copy_hires.sh ├── copy.sh └── ReadMe.md ├── Figure ├── t01-water.sh ├── t02-change.sh ├── s01-water.sh ├── s02-change.sh ├── src │ ├── set_name.f90 │ ├── conv_water.f90 │ └── conv_change.f90 ├── draw-change.py └── draw-water.py ├── ReadMe.md ├── osmconf_water.ini └── osmconf.ini /calc_2021Feb/add_stream/src/nohup.out: -------------------------------------------------------------------------------- 1 | nohup: auto.sh: No such file or directory 2 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ./a01-preset.sh 3 | ./a02-waterlayer.sh -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !*/ 3 | !*.* 4 | !LICENSE 5 | !Mkinclude_* 6 | !Makefile 7 | .DS_Store 8 | # 9 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/tmp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s04-osm2shp.sh -180 180 -60 90 4 | ./s05-rasterlize.sh -180 180 -60 90 5 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/tmp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s04-osm2shp.sh -180 180 -60 90 4 | ./s05-rasterlize.sh -180 180 -60 90 5 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/tmp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s04-osm2shp.sh -180 180 -60 90 4 | ./s05-rasterlize.sh -180 180 -60 90 5 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s01-rasterlize.sh 120 155 20 50 4 | ./s02-upscale.sh 120 155 20 50 5 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s01-merge_raster.sh 120 150 20 50 4 | ./s02-upscale.sh 120 150 20 50 5 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## OSM water layer shapefile 4 | ln -sf ../../calc_2021Feb/add_canal/shp . 5 | 6 | ./s01-rasterlize.sh 120 155 20 50 7 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## OSM water layer shapefile 4 | ln -shf ../../calc_2021Feb/add_stream/shp . 5 | 6 | ./s05-rasterlize.sh 120 155 20 50 7 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/VisualizationMemo.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/global-hydrodynamics/OSM_WaterLayer/HEAD/calc_2021Feb/merge_water/Figure/VisualizationMemo.docx -------------------------------------------------------------------------------- /hires_2021Feb/add_river/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## OSM water layer shapefile 4 | ln -sf ../../calc_2021Feb/add_river/shp . 5 | 6 | ./s01-rasterlize.sh 120 155 20 50 7 | 8 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s01-merge_raster.sh -180 180 -60 90 4 | ./s02-add_hdr.sh -180 180 -60 90 5 | ./s03-gdal.sh -180 180 -60 90 6 | 7 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/memo_class.md: -------------------------------------------------------------------------------- 1 | water class: 2 | 3 | 0: land 4 | 1: ocean 5 | 2: large water body (poligon) 6 | 3: majopr river 7 | 4: canal 8 | 5: small stream 9 | 10 | -------------------------------------------------------------------------------- /OSM_sea/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s00-link.sh 4 | 5 | ## for global 5sec 6 | ./s01-auto_conv.sh 135 140 35 40 7 | 8 | ## for Japan 1sec 9 | ./s02-conv_1sec.sh 135 140 35 40 10 | 11 | exit -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s00-link.sh 4 | ./s01-extract_water.sh 5 | ./s02-divide_lons.sh 6 | ./s03-divide_lonlat.sh 7 | ./s04-osm2shp.sh -180 180 -60 90 8 | ./s05-rasterlize.sh -180 180 -60 90 9 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s00-link.sh 4 | ./s01-extract_water.sh 5 | ./s02-divide_lons.sh 6 | ./s03-divide_lonlat.sh 7 | ./s04-osm2shp.sh -180 180 -60 90 8 | ./s05-rasterlize.sh -180 180 -60 90 9 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/auto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s00-link.sh 4 | ./s01-extract_water.sh 5 | ./s02-divide_lons.sh 6 | ./s03-divide_lonlat.sh 7 | ./s04-osm2shp.sh -180 180 -60 90 8 | ./s05-rasterlize.sh -180 180 -60 90 9 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/readme.md: -------------------------------------------------------------------------------- 1 | # Visualization Memo 2 | Show difference to G3WBM (Landsat - 90m) Water Mask 3 | 4 | - Water Only in OSM : Red 5 | - Water Only in G3WBM : Green 6 | - Water in both : Blue 7 | 8 | -------------------------------------------------------------------------------- /OSM_sea/s00-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### 3sec elevation data for reference 4 | ln -sf /home/yamadai/work/data/DEM/MERIT_DEM/v11 DEM 5 | 6 | ### 1sec ref data for Japan 7 | ln -sf /Users/yamadai/work/JapanFlowDir/input/DEM_1sec DEM_1sec 8 | 9 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/t02-upscale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON=$1 4 | LAT=$2 5 | CNAME=`./src/set_name $LON $LAT` 6 | 7 | ./src/upscale_1sec $LON $LAT 8 | ./src/wrte_ctl_30m $LON $LAT ${CNAME}.bil ${CNAME}.ctl 9 | mv -f ${CNAME}.* 1deg_30m 10 | 11 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s00-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### OSM water poligon (sea mask) 4 | ln -sf ../../OSM_sea/5deg coast 5 | ln -sf ../../OSM_sea/download shp_coast 6 | 7 | ### GDAL OSM configulation file 8 | cp ../../osmconf_water.ini . 9 | 10 | -------------------------------------------------------------------------------- /distribute/copy_hires.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TAG="v2.0_2021Feb" 4 | 5 | INPBIN="../../hires_2021Feb/merge_water/" 6 | 7 | cd $TAG 8 | 9 | cp -r $INPBIN/1deg_10m . 10 | cp -r $INPBIN/1deg_30m . 11 | 12 | tar cvfz 1deg_10m.tar.gz 1deg_10m 13 | tar cvfz 1deg_30m.tar.gz 1deg_30m 14 | 15 | 16 | ### 17 | 18 | 19 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s00-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### GDAL OSM configulation file 4 | cp ../../osmconf_water.ini . 5 | 6 | ### OSM water poligon (sea mask) 7 | ln -sf ../extract_water/coast 8 | ln -sf ../extract_water/shp_coast 9 | 10 | mkdir -p osm 11 | cd osm 12 | ln -sf ../../extract_water/osm/water . 13 | cd .. 14 | 15 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s00-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### GDAL OSM configulation file 4 | cp ../../osmconf_water.ini . 5 | 6 | ### OSM water poligon (sea mask) 7 | ln -sf ../extract_water/coast 8 | ln -sf ../extract_water/shp_coast 9 | 10 | mkdir -p osm 11 | cd osm 12 | ln -sf ../../extract_water/osm/water . 13 | cd .. 14 | 15 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s00-link.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### GDAL OSM configulation file 4 | cp ../../osmconf_water.ini . 5 | 6 | ### OSM water poligon (sea mask) 7 | ln -sf ../extract_water/coast 8 | ln -sf ../extract_water/shp_coast 9 | 10 | mkdir -p osm 11 | cd osm 12 | ln -sf ../../extract_water/osm/water . 13 | cd .. 14 | 15 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/u05-merge_planet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | INPFILE="./osm/planet.osm.pbf" 5 | ADDFILE="./tag_mod/water_add-relation.osm" 6 | OUTFILE="./osm/planet-mod.osm.pbf" 7 | 8 | osmosis --rx $ADDFILE --rbf $INPFILE --merge conflictResolutionMethod=lastSource --wb $OUTFILE -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | conv_form\ 6 | set_name\ 7 | 8 | all: $(TARGETS) 9 | 10 | clean: 11 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 12 | 13 | .SUFFIXES : .f90 14 | .f90: 15 | $(FC) ${FFLAGS} $^ -o $@ 16 | -------------------------------------------------------------------------------- /OSM_sea/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | set_name\ 6 | set_window\ 7 | set_window_1sec\ 8 | wrte_ctl_5deg\ 9 | 10 | all: $(TARGETS) 11 | 12 | clean: 13 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 14 | 15 | .SUFFIXES : .f90 16 | .f90: 17 | $(FC) ${FFLAGS} $^ -o $@ 18 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/t04-draw.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | EAST=$(( $WEST + 5 )) 5 | SOUTH=$2 6 | NORTH=$(( $SOUTH + 5 )) 7 | 8 | #################################### 9 | 10 | CNAME=`./src/set_name $WEST $SOUTH` 11 | 12 | ./src/conv_form $WEST $SOUTH 13 | 14 | python ./draw.py $WEST $EAST $SOUTH $NORTH $CNAME width 15 | 16 | rm -f var_${CNAME}.bin 17 | 18 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | wrte_ctl_5deg\ 9 | 10 | all: $(TARGETS) 11 | 12 | clean: 13 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 14 | 15 | .SUFFIXES : .f90 16 | .f90: 17 | $(FC) ${FFLAGS} $^ -o $@ 18 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | wrte_ctl_5deg\ 9 | 10 | all: $(TARGETS) 11 | 12 | clean: 13 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 14 | 15 | .SUFFIXES : .f90 16 | .f90: 17 | $(FC) ${FFLAGS} $^ -o $@ 18 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | wrte_ctl_5deg\ 9 | 10 | all: $(TARGETS) 11 | 12 | clean: 13 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 14 | 15 | .SUFFIXES : .f90 16 | .f90: 17 | $(FC) ${FFLAGS} $^ -o $@ 18 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | merge_mask\ 6 | set_name\ 7 | wrte_ctl_5deg\ 8 | wrte_hdr_int1\ 9 | 10 | all: $(TARGETS) 11 | 12 | clean: 13 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 14 | 15 | .SUFFIXES : .f90 16 | .f90: 17 | $(FC) ${FFLAGS} $^ -o $@ 18 | -------------------------------------------------------------------------------- /Figure/t01-water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p osm2021 4 | 5 | WEST=$1 6 | EAST=$(( $WEST + 5 )) 7 | SOUTH=$2 8 | NORTH=$(( $SOUTH + 5 )) 9 | 10 | #################################### 11 | 12 | CNAME=`./src/set_name $WEST $SOUTH` 13 | 14 | ./src/conv_water $WEST $SOUTH 15 | 16 | if [ -f wat_${CNAME}.bin ]; then 17 | python ./draw-water.py $WEST $SOUTH $CNAME osm2021 18 | rm -f wat_${CNAME}.bin 19 | fi 20 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | merge_mask\ 6 | set_name\ 7 | upscale_1sec\ 8 | wrte_ctl_10m\ 9 | wrte_ctl_30m\ 10 | 11 | 12 | all: $(TARGETS) 13 | 14 | clean: 15 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 16 | 17 | .SUFFIXES : .f90 18 | .f90: 19 | $(FC) ${FFLAGS} $^ -o $@ 20 | 21 | 22 | -------------------------------------------------------------------------------- /Figure/t02-change.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p dif_2021-2015 4 | 5 | WEST=$1 6 | EAST=$(( $WEST + 5 )) 7 | SOUTH=$2 8 | NORTH=$(( $SOUTH + 5 )) 9 | 10 | #################################### 11 | 12 | CNAME=`./src/set_name $WEST $SOUTH` 13 | 14 | ./src/conv_change $WEST $SOUTH 15 | 16 | if [ -f dif_${CNAME}.bin ]; then 17 | python ./draw-change.py $WEST $SOUTH $CNAME dif_2021-2015 18 | rm -f dif_${CNAME}.bin 19 | fi 20 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | upscale_1sec\ 9 | wrte_ctl_10m\ 10 | wrte_ctl_30m\ 11 | 12 | 13 | all: $(TARGETS) 14 | 15 | clean: 16 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 17 | 18 | .SUFFIXES : .f90 19 | .f90: 20 | $(FC) ${FFLAGS} $^ -o $@ 21 | 22 | 23 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | upscale_1sec\ 9 | wrte_ctl_10m\ 10 | wrte_ctl_30m\ 11 | 12 | 13 | all: $(TARGETS) 14 | 15 | clean: 16 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 17 | 18 | .SUFFIXES : .f90 19 | .f90: 20 | $(FC) ${FFLAGS} $^ -o $@ 21 | 22 | 23 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | upscale_1sec\ 9 | wrte_ctl_10m\ 10 | wrte_ctl_30m\ 11 | 12 | 13 | all: $(TARGETS) 14 | 15 | clean: 16 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 17 | 18 | .SUFFIXES : .f90 19 | .f90: 20 | $(FC) ${FFLAGS} $^ -o $@ 21 | 22 | 23 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | marge_tmpfile\ 6 | set_name\ 7 | set_window\ 8 | upscale_1sec\ 9 | wrte_ctl_10m\ 10 | wrte_ctl_30m\ 11 | 12 | 13 | all: $(TARGETS) 14 | 15 | clean: 16 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 17 | 18 | .SUFFIXES : .f90 19 | .f90: 20 | $(FC) ${FFLAGS} $^ -o $@ 21 | 22 | 23 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/Makefile: -------------------------------------------------------------------------------- 1 | FC = ifort 2 | FFLAGS = -O3 -warn all -assume byterecl -heap-arrays -nogen-interfaces 3 | 4 | TARGETS=\ 5 | add_lake\ 6 | check_relation\ 7 | check_type\ 8 | marge_tmpfile\ 9 | set_bounds\ 10 | set_name\ 11 | set_window\ 12 | wrte_ctl_5deg\ 13 | 14 | all: $(TARGETS) 15 | 16 | clean: 17 | $(RM) -rf *.o *.s core *~ *trace *.mod *.dSYM $(TARGETS) 18 | 19 | .SUFFIXES : .f90 20 | .f90: 21 | $(FC) ${FFLAGS} $^ -o $@ 22 | -------------------------------------------------------------------------------- /distribute/copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | TAG="v2.0_2021Feb" 4 | 5 | INPPBF="../../calc_2021Feb/extract_water/osm/water/planet-all.osm.pbf" 6 | INPTIF="../../calc_2021Feb/merge_water/tif" 7 | INPBIN="../../calc_2021Feb/merge_water/5deg" 8 | 9 | mkdir -p $TAG 10 | cd $TAG 11 | 12 | cp $INPPBF ./OSM_WaterLayer.pbf 13 | cp -r $INPTIF ./OSM_WaterLayer_tif 14 | cp -r $INPBIN ./5deg 15 | 16 | tar cvfz OSM_WaterLayer_tif.tar.gz OSM_WaterLayer_tif 17 | tar cvfz 5deg.tar.gz 5deg 18 | 19 | 20 | -------------------------------------------------------------------------------- /OSM_sea/t02-1sec_gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export GDAL_CACHEMAX=512 4 | 5 | LON=$1 6 | LAT=$2 7 | 8 | CNAME=`./src/set_name $LON $LAT` 9 | 10 | OUTFILE="${CNAME}.bin" 11 | CTLFILE="${CNAME}.ctl" 12 | 13 | SHPFILE="./download/water_polygons.shp" 14 | LAYER="water_polygons" 15 | 16 | rm -f $OUTFILE 17 | 18 | WINDOW=`./src/set_window_1sec $LON $LAT` 19 | gdal_rasterize -of EHdr -ot Byte -burn 1 -at -tr 0.00027777777778 0.00027777777778 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 20 | 21 | mv ${CNAME}.* coast_1sec/ 22 | -------------------------------------------------------------------------------- /OSM_sea/t01-auto_gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export GDAL_CACHEMAX=512 4 | 5 | LON=$1 6 | LAT=$2 7 | 8 | CNAME=`./src/set_name $LON $LAT` 9 | 10 | OUTFILE="${CNAME}_sea.bil" 11 | CTLFILE="${CNAME}_sea.ctl" 12 | 13 | SHPFILE="./download/water_polygons.shp" 14 | LAYER="water_polygons" 15 | 16 | rm -f $OUTFILE 17 | 18 | WINDOW=`./src/set_window $LON $LAT` 19 | gdal_rasterize -of EHdr -ot Byte -burn 1 -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 20 | 21 | ./src/wrte_ctl_5deg $LON $LAT $OUTFILE $CTLFILE 22 | 23 | mv ${CNAME}_sea.* 5deg 24 | -------------------------------------------------------------------------------- /OSM_sea/src/set_window_1sec.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+1 15 | n0=s0+1 16 | 17 | print '(4f20.8)', w0, s0, e0, n0 18 | 19 | end program check_area -------------------------------------------------------------------------------- /OSM_sea/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+5 15 | n0=s0+5 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+5 15 | n0=s0+5 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_river/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+5 15 | n0=s0+5 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+5 15 | n0=s0+5 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./18000.*0.0) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+1 15 | n0=s0+1 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./18000.*0.0) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+1 15 | n0=s0+1 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./1200.*0.5) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+5 15 | n0=s0+5 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./18000.*0.0) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+1 15 | n0=s0+1 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/set_window.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | real :: hres 8 | parameter (hres=1./18000.*0.0) 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) w0 12 | call getarg(2,buf) 13 | read(buf,*) s0 14 | e0=w0+1 15 | n0=s0+1 16 | 17 | print '(4f20.8)', w0-hres, s0-hres, e0-hres, n0-hres 18 | 19 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/s01-merge_raster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p 1deg_10m 4 | 5 | LON_ORI=120 6 | LON_END=150 7 | LAT_ORI=20 8 | LAT_END=50 9 | 10 | WEST=$LON_ORI 11 | while [ $WEST -lt $LON_END ]; 12 | do 13 | SOUTH=$LAT_ORI 14 | while [ $SOUTH -lt $LAT_END ]; 15 | do 16 | echo $WEST $SOUTH 17 | CNAME=`./src/set_name $WEST $SOUTH` 18 | if [ -f ../extract_water/1deg_10m/${CNAME}.bil ]; then 19 | ./src/merge_mask $CNAME & 20 | ./src/wrte_ctl_10m $WEST $SOUTH ${CNAME}.bil ${CNAME}.ctl 21 | mv ${CNAME}.ctl 1deg_10m 22 | fi 23 | SOUTH=`expr $SOUTH + 1` 24 | done 25 | wait 26 | WEST=`expr $WEST + 1` 27 | done 28 | -------------------------------------------------------------------------------- /OSM_sea/s01-auto_conv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | EAST=$2 5 | SOUTH=$3 6 | NORTH=$4 7 | 8 | mkdir -p 5deg 9 | 10 | LAT=$SOUTH 11 | while [ $LAT -lt $NORTH ]; 12 | do 13 | LON=$WEST 14 | while [ $LON -lt $EAST ]; 15 | do 16 | CNAME=`./src/set_name $LON $LAT` 17 | if [ -e ./DEM/${CNAME}.bin ]; then 18 | ./t01-auto_gdal.sh $LON $LAT & 19 | fi 20 | 21 | NUM=`ps | grep t01-auto_gdal.sh | wc -l | awk '{print $1}'` 22 | while [ $NUM -ge 10 ]; 23 | do 24 | sleep 5 25 | NUM=`ps | grep t01-auto_gdal.sh | wc -l | awk '{print $1}'` 26 | done 27 | 28 | LON=$(( $LON + 5 )) 29 | done 30 | LAT=$(( $LAT + 5 )) 31 | done 32 | 33 | wait -------------------------------------------------------------------------------- /OSM_sea/s02-conv_1sec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | EAST=$2 5 | SOUTH=$3 6 | NORTH=$4 7 | 8 | mkdir -p coast_1sec 9 | 10 | LAT=$SOUTH 11 | while [ $LAT -lt $NORTH ]; 12 | do 13 | LON=$WEST 14 | while [ $LON -lt $EAST ]; 15 | do 16 | CNAME=`./src/set_name $LON $LAT` 17 | if [ -e ./DEM_jpn/${CNAME}.bin ]; then 18 | ./t02-1sec_gdal.sh $LON $LAT & 19 | fi 20 | 21 | NUM=`ps | grep t02-1sec_gdal.sh | wc -l | awk '{print $1}'` 22 | while [ $NUM -ge 10 ]; 23 | do 24 | sleep 5 25 | NUM=`ps | grep t02-1sec_gdal.sh | wc -l | awk '{print $1}'` 26 | done 27 | 28 | LON=$(( $LON + 1 )) 29 | done 30 | LAT=$(( $LAT + 1 )) 31 | done 32 | 33 | wait -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/s02-add_hdr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON_ORI=-180 4 | LON_END=180 5 | LAT_ORI=-60 6 | LAT_END=90 7 | 8 | LON_ORI=$1 9 | LON_END=$2 10 | LAT_ORI=$3 11 | LAT_END=$4 12 | 13 | BASE=`pwd` 14 | 15 | #################################### 16 | 17 | SOUTH=$LAT_ORI 18 | while [ $SOUTH -lt $LAT_END ]; 19 | do 20 | WEST=$LON_ORI 21 | while [ $WEST -lt $LON_END ]; 22 | do 23 | CNAME=`./src/set_name $WEST $SOUTH` 24 | if [ -f ./5deg/${CNAME}.bil ]; then 25 | ./src/wrte_hdr_int1 $WEST $SOUTH ${CNAME}.hdr 26 | mv ${CNAME}.hdr ./5deg 27 | 28 | fi 29 | WEST=$(( $WEST + 5 )) 30 | done 31 | SOUTH=$(( $SOUTH + 5 )) 32 | done 33 | wait 34 | 35 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/s01-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | mkdir -p 1deg_10m 5 | 6 | LON_ORI=$1 7 | LON_END=$2 8 | LAT_ORI=$3 9 | LAT_END=$4 10 | 11 | WEST=$LON_ORI 12 | while [ $WEST -lt $LON_END ]; 13 | do 14 | SOUTH=$LAT_ORI 15 | while [ $SOUTH -lt $LAT_END ]; 16 | do 17 | echo $WEST $SOUTH 18 | ./t01-gdal.sh $WEST $SOUTH & 19 | 20 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 21 | while [ $NUM -gt 8 ]; 22 | do 23 | sleep 1 24 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 25 | done 26 | 27 | SOUTH=`expr $SOUTH + 5` 28 | done 29 | WEST=`expr $WEST + 5` 30 | done 31 | 32 | wait -------------------------------------------------------------------------------- /hires_2021Feb/add_river/s01-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | mkdir -p 1deg_10m 5 | 6 | LON_ORI=$1 7 | LON_END=$2 8 | LAT_ORI=$3 9 | LAT_END=$4 10 | 11 | WEST=$LON_ORI 12 | while [ $WEST -lt $LON_END ]; 13 | do 14 | SOUTH=$LAT_ORI 15 | while [ $SOUTH -lt $LAT_END ]; 16 | do 17 | echo $WEST $SOUTH 18 | ./t01-gdal.sh $WEST $SOUTH & 19 | 20 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 21 | while [ $NUM -gt 8 ]; 22 | do 23 | sleep 1 24 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 25 | done 26 | 27 | SOUTH=`expr $SOUTH + 5` 28 | done 29 | WEST=`expr $WEST + 5` 30 | done 31 | 32 | wait -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/check_type.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: id, irelation, itype 6 | 7 | character*128 :: rfile, buf 8 | 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) id 12 | 13 | rfile='./tag_mod/water-relation-id.txt' 14 | 1000 continue 15 | read(21,*,end=1090) irelation, itype 16 | if( id==irelation ) then 17 | print *, itype 18 | stop 19 | endif 20 | goto 1000 21 | 1090 continue 22 | print *, -9 23 | 24 | end program check_relation 25 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/s01-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | mkdir -p 1deg_10m 5 | 6 | LON_ORI=$1 7 | LON_END=$2 8 | LAT_ORI=$3 9 | LAT_END=$4 10 | 11 | WEST=$LON_ORI 12 | while [ $WEST -lt $LON_END ]; 13 | do 14 | SOUTH=$LAT_ORI 15 | while [ $SOUTH -lt $LAT_END ]; 16 | do 17 | echo $WEST $SOUTH 18 | ./t01-gdal.sh $WEST $SOUTH & 19 | 20 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 21 | while [ $NUM -gt 8 ]; 22 | do 23 | sleep 1 24 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 25 | done 26 | 27 | SOUTH=`expr $SOUTH + 5` 28 | done 29 | WEST=`expr $WEST + 5` 30 | done 31 | 32 | wait -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/s02-upscale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | mkdir -p 1deg_30m 5 | 6 | LON_ORI=120 7 | LON_END=155 8 | LAT_ORI=20 9 | LAT_END=50 10 | 11 | WEST=$LON_ORI 12 | while [ $WEST -lt $LON_END ]; 13 | do 14 | SOUTH=$LAT_ORI 15 | while [ $SOUTH -lt $LAT_END ]; 16 | do 17 | echo $WEST $SOUTH 18 | ./t02-upscale.sh $WEST $SOUTH & 19 | 20 | NUM=`ps aux | grep $USER | grep t02-upscale.sh | wc -l | awk '{print $1}'` 21 | while [ $NUM -gt 8 ]; 22 | do 23 | sleep 0.1 24 | NUM=`ps aux | grep $USER | grep t02-upscale.sh | wc -l | awk '{print $1}'` 25 | done 26 | 27 | SOUTH=`expr $SOUTH + 1` 28 | done 29 | WEST=`expr $WEST + 1` 30 | done 31 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/check_type.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: id, irelation, itype 6 | 7 | character*128 :: rfile, buf 8 | 9 | ! =============================================== 10 | call getarg(1,buf) 11 | read(buf,*) id 12 | 13 | rfile='./tag_mod/water-relation-id.txt' 14 | 1000 continue 15 | read(21,*,end=1090) irelation, itype 16 | if( id==irelation ) then 17 | print *, itype 18 | stop 19 | endif 20 | goto 1000 21 | 1090 continue 22 | print *, -9 23 | 24 | end program check_relation 25 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/s01-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | mkdir -p 1deg_10m 5 | 6 | LON_ORI=$1 7 | LON_END=$2 8 | LAT_ORI=$3 9 | LAT_END=$4 10 | 11 | WEST=$LON_ORI 12 | while [ $WEST -lt $LON_END ]; 13 | do 14 | SOUTH=$LAT_ORI 15 | while [ $SOUTH -lt $LAT_END ]; 16 | do 17 | echo $WEST $SOUTH 18 | ./t01-gdal.sh $WEST $SOUTH & 19 | 20 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 21 | while [ $NUM -gt 8 ]; 22 | do 23 | sleep 1 24 | NUM=`ps aux | grep $USER | grep ./t01-gdal.sh | wc -l | awk '{print $1}'` 25 | done 26 | 27 | SOUTH=`expr $SOUTH + 5` 28 | done 29 | WEST=`expr $WEST + 5` 30 | done 31 | 32 | wait -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/a02-waterlayer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./s00-link 4 | 5 | # Extract water-related layers 6 | ./s01-extract_water.sh > log_s01.txt 2> err_s01.txt 7 | 8 | # Devide lon & lat 9 | ./s02-divide_lons.sh > log_s02.txt 2> err_s02.txt 10 | ./s03-divide_lonlat.sh > log_s03.txt 2> err_s03.txt 11 | 12 | # convert to shapefile and rasterlize 13 | ./s04-osm2shp.sh -180 180 -60 90 > log_s04.txt 2> err_s04.txt 14 | ./s05-rasterlize.sh -180 180 -60 90 > log_s05.txt 2> err_s05.txt 15 | 16 | #cd fig 17 | #./s01-jpg.sh -180 180 -60 90 18 | 19 | mv log_s*.txt ./log/ 20 | mv err_s*.txt ./log/ -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/s01-merge_raster.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p 5deg 4 | 5 | LON_ORI=-180 6 | LON_END=180 7 | LAT_ORI=-60 8 | LAT_END=90 9 | 10 | LON_ORI=$1 11 | LON_END=$2 12 | LAT_ORI=$3 13 | LAT_END=$4 14 | 15 | WEST=$LON_ORI 16 | while [ $WEST -lt $LON_END ]; 17 | do 18 | SOUTH=$LAT_ORI 19 | while [ $SOUTH -lt $LAT_END ]; 20 | do 21 | echo $WEST $SOUTH 22 | CNAME=`./src/set_name $WEST $SOUTH` 23 | if [ -f ../extract_water/5deg/${CNAME}.bil ]; then 24 | ./src/merge_mask $CNAME & 25 | ./src/wrte_ctl_5deg $WEST $SOUTH ${CNAME}.bil ${CNAME}.ctl 26 | mv ${CNAME}.ctl 5deg 27 | fi 28 | SOUTH=`expr $SOUTH + 5` 29 | done 30 | wait 31 | WEST=`expr $WEST + 5` 32 | done 33 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s05-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | USER=`whoami` 5 | mkdir -p 5deg 6 | 7 | LON_ORI=$1 8 | LON_END=$2 9 | LAT_ORI=$3 10 | LAT_END=$4 11 | 12 | WEST=$LON_ORI 13 | while [ $WEST -lt $LON_END ]; 14 | do 15 | SOUTH=$LAT_ORI 16 | while [ $SOUTH -lt $LAT_END ]; 17 | do 18 | echo $WEST $SOUTH 19 | ./t05-gdal.sh $WEST $SOUTH & 20 | 21 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 22 | while [ $NUM -gt 18 ]; 23 | do 24 | sleep 1 25 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 26 | done 27 | 28 | SOUTH=`expr $SOUTH + 5` 29 | done 30 | WEST=`expr $WEST + 5` 31 | done -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s05-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | mkdir -p 5deg 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | LON_ORI=$1 12 | LON_END=$2 13 | LAT_ORI=$3 14 | LAT_END=$4 15 | 16 | 17 | WEST=$LON_ORI 18 | while [ $WEST -lt $LON_END ]; 19 | do 20 | SOUTH=$LAT_ORI 21 | while [ $SOUTH -lt $LAT_END ]; 22 | do 23 | echo $WEST $SOUTH 24 | ./t05-gdal.sh $WEST $SOUTH & 25 | 26 | NUM=`ps | grep t05-gdal.sh | wc -l | awk '{print $1}'` 27 | while [ $NUM -gt 8 ]; 28 | do 29 | sleep 2 30 | NUM=`ps | grep t05-gdal.sh | wc -l | awk '{print $1}'` 31 | done 32 | 33 | SOUTH=`expr $SOUTH + 5` 34 | done 35 | wait 36 | WEST=`expr $WEST + 5` 37 | done 38 | wait 39 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s05-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | mkdir -p 5deg 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | LON_ORI=$1 12 | LON_END=$2 13 | LAT_ORI=$3 14 | LAT_END=$4 15 | 16 | WEST=$LON_ORI 17 | while [ $WEST -lt $LON_END ]; 18 | do 19 | SOUTH=$LAT_ORI 20 | while [ $SOUTH -lt $LAT_END ]; 21 | do 22 | echo $WEST $SOUTH 23 | ./t05-gdal.sh $WEST $SOUTH & 24 | 25 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 26 | while [ $NUM -gt 18 ]; 27 | do 28 | sleep 1 29 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 30 | done 31 | 32 | SOUTH=`expr $SOUTH + 5` 33 | done 34 | WEST=`expr $WEST + 5` 35 | done 36 | wait 37 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s05-rasterlize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | mkdir -p 5deg 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | LON_ORI=$1 12 | LON_END=$2 13 | LAT_ORI=$3 14 | LAT_END=$4 15 | 16 | WEST=$LON_ORI 17 | while [ $WEST -lt $LON_END ]; 18 | do 19 | SOUTH=$LAT_ORI 20 | while [ $SOUTH -lt $LAT_END ]; 21 | do 22 | echo $WEST $SOUTH 23 | ./t05-gdal.sh $WEST $SOUTH & 24 | 25 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 26 | while [ $NUM -gt 18 ]; 27 | do 28 | sleep 1 29 | NUM=`ps aux | grep $USER | grep t05-gdal.sh | wc -l | awk '{print $1}'` 30 | done 31 | 32 | SOUTH=`expr $SOUTH + 5` 33 | done 34 | WEST=`expr $WEST + 5` 35 | done 36 | wait 37 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/a01-preset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | # requires OSMOSIS and GDAL. 5 | # Download latest planet.pbf, and save it in osm/ directoly 6 | # compile the code in src/ in advance. 7 | 8 | mkdir -p log 9 | 10 | # u01 ~ u05 11 | ## To fix bug in OSM file, some "relation" tags should be added. 12 | ## planet.osm.pbf is modified to planet-mod.osm.pbf 13 | 14 | ./u01-notag_relations.sh > log_u01.txt 2> err_u01.txt 15 | ./u02-tag_relations.sh > log_u02.txt 2> err_u02.txt 16 | ./u03-ways.sh > log_u03.txt 2> err_u03.txt 17 | ./u04-extract-id.sh > log_u04.txt 2> err_u04.txt 18 | ./u05-merge_planet.sh > log_u05.txt 2> err_u05.txt 19 | 20 | mv log_u*.txt ./log/ 21 | mv err_u*.txt ./log/ -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/u02-tag_relations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | ### extract waterway & natural-water, relations and ways 5 | 6 | OSMFILE="./tag_mod/only-relation.osm" 7 | OUTFILE="./tag_mod/tag-relation.osm" 8 | osmosis --fast-read-xml $OSMFILE --tf accept-relations natural=water --wb tmp1.pbf & 9 | osmosis --fast-read-xml $OSMFILE --tf accept-relations waterway=* --wb tmp2.pbf & 10 | osmosis --fast-read-xml $OSMFILE --tf accept-relations landuse=reservoir --wb tmp3.pbf & 11 | wait 12 | 13 | osmosis --rbf tmp1.pbf --rbf tmp2.pbf --rbf tmp3.pbf --merge --merge --wx $OUTFILE 14 | rm -f tmp?.pbf 15 | 16 | OSMFILE="./tag_mod/tag-relation.osm" 17 | cat $OSMFILE | grep 'type="way"' | grep 'role="outer"' | awk -F'"' '{print $4}' > ./tag_mod/way-id2.txt 18 | -------------------------------------------------------------------------------- /OSM_sea/ReadMe.md: -------------------------------------------------------------------------------- 1 | # OSM water layer scripts 2 | The scripts to generate OSM Water Layer 3 | http://hydro.iis.u-tokyo.ac.jp/~yamadai/OSM_water/index.html 4 | 5 | ## [1] Prepare "sea mask" from OSM water-polygons 6 | Work in OSM_sea/ directory. 7 | 8 | ### Download OSM water polygons 9 | - Download water-polygons-split-4326.zip from https://osmdata.openstreetmap.de/data/water-polygons.html. 10 | - Put the zip file in download/ directory, and extract the data. 11 | 12 | ### Rasterlize at 5deg tile (3sec resolution) and 1deg tile (1sec resolution for Japan) 13 | - s00-link.sh: Link MERIT DEM elevation and J-FlwDir elevation as reference to the tile with land. 14 | - s01-auto_conv.sh: script to convert water-polygons shapefile to 5deg raster tile. 15 | - s02-conv_1sec: script to convert water-polygons shapefile to 5deg raster tile (Japan use) 16 | 17 | -------------------------------------------------------------------------------- /distribute/ReadMe.md: -------------------------------------------------------------------------------- 1 | # OSM water layer data info 2 | 3 | ## Water classification in rasterlized data 4 | 5 | ### [Standard data: tif/ , 5deg/ ] 6 | **90m (3sec) resolution product** 7 | Below values are used in rasterlized data. 8 | 0: land 9 | 1: ocean 10 | 2: large water body (poligon) 11 | 3: majopr river 12 | 4: canal 13 | 5: small stream 14 | 15 | ### [High resolution data: 1deg_10m/ ] 16 | **10m resolution product** 17 | Below values are used in rasterlized data. 18 | 0: land 19 | 1: ocean 20 | 2: large water body (poligon) 21 | 3: majopr river 22 | 4: canal 23 | 5: small stream 24 | 25 | ### [High resolution data: 1deg_30m/ ] 26 | **30m resolution upscaled product** 27 | 10-100: fraction of water treated as polygon 28 | 5: water tagged as river (line, without area) 29 | 2: water tagged as canal (line, without area) 30 | 1: water tagged as stream (line, without area) 31 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/s02-upscale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p 1deg_30m 4 | 5 | LON_ORI=$1 6 | LON_END=$2 7 | LAT_ORI=$3 8 | LAT_END=$4 9 | 10 | WEST=$LON_ORI 11 | while [ $WEST -lt $LON_END ]; 12 | do 13 | SOUTH=$LAT_ORI 14 | while [ $SOUTH -lt $LAT_END ]; 15 | do 16 | CNAME=`./src/set_name $WEST $SOUTH` 17 | if [ -f ./1deg_10m/${CNAME}.bil ]; then 18 | echo $WEST $SOUTH 19 | 20 | ./src/upscale_1sec $WEST $SOUTH & 21 | ./src/wrte_ctl_30m $WEST $SOUTH ${CNAME}.bil ${CNAME}.ctl 22 | mv -f ${CNAME}.ctl 1deg_30m/ 23 | 24 | NUM=`ps -U yamadai | grep src/upscale_1sec | wc -l | awk '{print $1}'` 25 | while [ $NUM -gt 8 ]; 26 | do 27 | sleep 0.1 28 | NUM=`ps -U yamadai | grep src/upscale_1sec | wc -l | awk '{print $1}'` 29 | done 30 | fi 31 | 32 | SOUTH=`expr $SOUTH + 1` 33 | done 34 | WEST=`expr $WEST + 1` 35 | done 36 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s01-extract_water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | mkdir -p java.tmp 4 | mkdir -p osm/bank 5 | 6 | ### extract waterway & natural-water, relations and ways 7 | 8 | INPFILE2="./osm/water/planet-way_r.osm.pbf" 9 | OUTFILE2="./osm/bank/planet-bank_r.osm.pbf" 10 | osmosis --rbf $INPFILE2 --tf accept-relations waterway=riverbank,river --uw --un --wb $OUTFILE2 & 11 | 12 | INPFILE5="./osm/water/planet-way_w.osm.pbf" 13 | OUTFILE5="./osm/bank/planet-bank_w.osm.pbf" 14 | osmosis --rbf $INPFILE5 --tf reject-relations --tf accept-ways waterway=riverbank,river --un --wb $OUTFILE5 & 15 | 16 | wait 17 | ### combine all water contents 18 | 19 | OUTFILE2="./osm/bank/planet-bank_r.osm.pbf" 20 | OUTFILE5="./osm/bank/planet-bank_w.osm.pbf" 21 | 22 | MERGEFILE="./osm/bank/planet-all.osm.pbf" 23 | 24 | osmosis --rbf $OUTFILE5 --rbf $OUTFILE2 --merge --wb $MERGEFILE 25 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s01-extract_water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | mkdir -p java.tmp 4 | mkdir -p osm/canal 5 | 6 | ### extract waterway & natural-water, relations and ways 7 | 8 | INPFILE2="./osm/water/planet-way_r.osm.pbf" 9 | OUTFILE2="./osm/canal/planet-can_r.osm.pbf" 10 | osmosis --rbf $INPFILE2 --tf accept-relations waterway=canal,drain,ditch --uw --un --wb $OUTFILE2 & 11 | 12 | INPFILE5="./osm/water/planet-way_w.osm.pbf" 13 | OUTFILE5="./osm/canal/planet-can_w.osm.pbf" 14 | osmosis --rbf $INPFILE5 --tf reject-relations --tf accept-ways waterway=canal,drain,ditch --un --wb $OUTFILE5 & 15 | 16 | wait 17 | ### combine all water contents 18 | 19 | OUTFILE2="./osm/canal/planet-can_r.osm.pbf" 20 | OUTFILE5="./osm/canal/planet-can_w.osm.pbf" 21 | 22 | MERGEFILE="./osm/canal/planet-all.osm.pbf" 23 | 24 | osmosis --rbf $OUTFILE5 --rbf $OUTFILE2 --merge --wb $MERGEFILE 25 | -------------------------------------------------------------------------------- /Figure/s01-water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | 5 | LON_ORI=$1 6 | LON_END=$2 7 | LAT_ORI=$3 8 | LAT_END=$4 9 | 10 | mkdir -p water 11 | 12 | #################################### 13 | 14 | SOUTH=${LAT_ORI} 15 | NORTH=`expr $SOUTH + 5` 16 | while [ $SOUTH -lt ${LAT_END} ]; 17 | do 18 | WEST=${LON_ORI} 19 | EAST=`expr $WEST + 5` 20 | while [ $WEST -lt ${LON_END} ]; 21 | do 22 | CNAME=`./src/set_name $WEST $SOUTH` 23 | 24 | if [ -f ./2021Feb/${CNAME}.bil ]; then 25 | 26 | ./t01-water.sh $WEST $SOUTH & 27 | 28 | NUM=`ps aux | grep $USER | grep t01-water.sh | wc -l | awk '{print $1}'` 29 | while [ $NUM -gt 16 ]; 30 | do 31 | sleep 1 32 | NUM=`ps aux | grep $USER | grep t01-water.sh | wc -l | awk '{print $1}'` 33 | done 34 | fi 35 | 36 | WEST=`expr $WEST + 5` 37 | EAST=`expr $WEST + 5` 38 | done 39 | SOUTH=`expr $SOUTH + 5` 40 | NORTH=`expr $SOUTH + 5` 41 | done 42 | wait 43 | 44 | -------------------------------------------------------------------------------- /Figure/s02-change.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | 5 | LON_ORI=$1 6 | LON_END=$2 7 | LAT_ORI=$3 8 | LAT_END=$4 9 | 10 | mkdir -p water 11 | 12 | #################################### 13 | 14 | SOUTH=${LAT_ORI} 15 | NORTH=`expr $SOUTH + 5` 16 | while [ $SOUTH -lt ${LAT_END} ]; 17 | do 18 | WEST=${LON_ORI} 19 | EAST=`expr $WEST + 5` 20 | while [ $WEST -lt ${LON_END} ]; 21 | do 22 | CNAME=`./src/set_name $WEST $SOUTH` 23 | 24 | if [ -f ./2021Feb/${CNAME}.bil ]; then 25 | 26 | ./t02-change.sh $WEST $SOUTH & 27 | 28 | NUM=`ps aux | grep $USER | grep t02-change.sh | wc -l | awk '{print $1}'` 29 | while [ $NUM -gt 16 ]; 30 | do 31 | sleep 1 32 | NUM=`ps aux | grep $USER | grep t02-change.sh | wc -l | awk '{print $1}'` 33 | done 34 | fi 35 | 36 | WEST=`expr $WEST + 5` 37 | EAST=`expr $WEST + 5` 38 | done 39 | SOUTH=`expr $SOUTH + 5` 40 | NORTH=`expr $SOUTH + 5` 41 | done 42 | wait 43 | 44 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/u04-extract-id.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | OSMFILE="./tag_mod/notag-relation.osm" 5 | 6 | awk -F'"' ' $1==" ./tag_mod/relation-id.txt 9 | 10 | awk -F'"' '{print $2}' ./tag_mod/list_way.txt > ./tag_mod/way-id.txt 11 | 12 | ./src/check_relation 13 | 14 | ./src/add_lake 15 | 16 | cat ./tag_mod/water_add-relation.osm | sed -e 's/1970-01-01T00:00:00Z/2015-06-22T00:00:00Z/g' | sed -e 's/version="-1"/version="1"/g' > tmp.osm 17 | osmosis --rx tmp.osm --sort --wx list_modify.osm 18 | 19 | rm -f tmp.osm 20 | mv list_modify.osm tag_mod/ 21 | 22 | ## modified relation data: ./tag_mod/list_modify.osm -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s01-extract_water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | mkdir -p java.tmp 4 | mkdir -p osm/stream 5 | 6 | ### extract waterway & natural-water, relations and ways 7 | 8 | INPFILE2="./osm/water/planet-way_r.osm.pbf" 9 | OUTFILE2="./osm/stream/planet-stream_r.osm.pbf" 10 | osmosis --rbf $INPFILE2 --tf accept-relations waterway=stream,brook,wadi,drystream --uw --un --wb $OUTFILE2 & 11 | 12 | INPFILE5="./osm/water/planet-way_w.osm.pbf" 13 | OUTFILE5="./osm/stream/planet-stream_w.osm.pbf" 14 | osmosis --rbf $INPFILE5 --tf reject-relations --tf accept-ways waterway=stream,brook,wadi,drystream --un --wb $OUTFILE5 & 15 | 16 | wait 17 | ### combine all water contents 18 | 19 | OUTFILE2="./osm/stream/planet-stream_r.osm.pbf" 20 | OUTFILE5="./osm/stream/planet-stream_w.osm.pbf" 21 | 22 | MERGEFILE="./osm/stream/planet-all.osm.pbf" 23 | 24 | osmosis --rbf $OUTFILE5 --rbf $OUTFILE2 --merge --wb $MERGEFILE 25 | -------------------------------------------------------------------------------- /Figure/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program list_file 2 | ! =============================================== 3 | implicit none 4 | ! 5 | real :: lon, lat 6 | 7 | character*1 :: ew, sn 8 | character*2 :: clat 9 | character*3 :: clon 10 | character*30 :: wfile 11 | 12 | character*128 :: buf 13 | ! =============================================== 14 | call getarg(1,buf) 15 | read(buf,*) lon 16 | call getarg(2,buf) 17 | read(buf,*) lat 18 | 19 | if( lon<0 )then 20 | ew='w' 21 | write(clon,'(i3.3)') int(-lon) 22 | else 23 | ew='e' 24 | write(clon,'(i3.3)') int(lon) 25 | endif 26 | 27 | if( lat<0 )then 28 | sn='s' 29 | write(clat,'(i2.2)') int(-lat) 30 | else 31 | sn='n' 32 | write(clat,'(i2.2)') int(lat) 33 | endif 34 | 35 | wfile=sn//clat//ew//clon 36 | print '(a7)', wfile 37 | 38 | end program list_file -------------------------------------------------------------------------------- /OSM_sea/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program list_file 2 | ! =============================================== 3 | implicit none 4 | ! 5 | real :: lon, lat 6 | 7 | character*1 :: ew, sn 8 | character*2 :: clat 9 | character*3 :: clon 10 | character*30 :: wfile 11 | 12 | character*128 :: buf 13 | ! =============================================== 14 | call getarg(1,buf) 15 | read(buf,*) lon 16 | call getarg(2,buf) 17 | read(buf,*) lat 18 | 19 | if( lon<0 )then 20 | ew='w' 21 | write(clon,'(i3.3)') int(-lon) 22 | else 23 | ew='e' 24 | write(clon,'(i3.3)') int(lon) 25 | endif 26 | 27 | if( lat<0 )then 28 | sn='s' 29 | write(clat,'(i2.2)') int(-lat) 30 | else 31 | sn='n' 32 | write(clat,'(i2.2)') int(lat) 33 | endif 34 | 35 | wfile=sn//clat//ew//clon 36 | print '(a7)', wfile 37 | 38 | end program list_file -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program list_file 2 | ! =============================================== 3 | implicit none 4 | ! 5 | real :: lon, lat 6 | 7 | character*1 :: ew, sn 8 | character*2 :: clat 9 | character*3 :: clon 10 | character*30 :: wfile 11 | 12 | character*128 :: buf 13 | ! =============================================== 14 | call getarg(1,buf) 15 | read(buf,*) lon 16 | call getarg(2,buf) 17 | read(buf,*) lat 18 | 19 | if( lon<0 )then 20 | ew='w' 21 | write(clon,'(i3.3)') int(-lon) 22 | else 23 | ew='e' 24 | write(clon,'(i3.3)') int(lon) 25 | endif 26 | 27 | if( lat<0 )then 28 | sn='s' 29 | write(clat,'(i2.2)') int(-lat) 30 | else 31 | sn='n' 32 | write(clat,'(i2.2)') int(lat) 33 | endif 34 | 35 | wfile=sn//clat//ew//clon 36 | print '(a7)', wfile 37 | 38 | end program list_file -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/set_name.f90: -------------------------------------------------------------------------------- 1 | program set_name 2 | ! =============================================== 3 | implicit none 4 | 5 | character*128 :: buf 6 | real :: lon, lat 7 | 8 | character*1 :: ew, sn 9 | character*2 :: clat 10 | character*3 :: clon 11 | character*7 :: cname 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | 18 | if( lon<0 )then 19 | ew='w' 20 | write(clon,'(i3.3)') int(-lon) 21 | else 22 | ew='e' 23 | write(clon,'(i3.3)') int(lon) 24 | endif 25 | 26 | if( lat<0 )then 27 | sn='s' 28 | write(clat,'(i2.2)') int(-lat) 29 | else 30 | sn='n' 31 | write(clat,'(i2.2)') int(lat) 32 | endif 33 | 34 | cname=sn//clat//ew//clon 35 | 36 | print '(a7)', cname 37 | 38 | end program set_name 39 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/u03-ways.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | ### extract waterway & natural-water, relations and ways 5 | 6 | PLANET="./osm/planet.osm.pbf" 7 | 8 | OUTFILE4="./tag_mod/planet-nat_w.osm.pbf" 9 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways natural=water --un --wb $OUTFILE4 & 10 | 11 | OUTFILE5="./tag_mod/planet-way_w.osm.pbf" 12 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways waterway=* --un --wb $OUTFILE5 & 13 | 14 | OUTFILE6="./tag_mod/planet-res_w.osm.pbf" 15 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways landuse=reservoir --un --wb $OUTFILE6 & 16 | 17 | wait 18 | 19 | OUTFILE="./tag_mod/only-way.pbf" 20 | osmosis --rbf $OUTFILE4 --rbf $OUTFILE5 --rbf $OUTFILE6 --merge --merge --wb $OUTFILE 21 | 22 | 23 | OSMFILE="./tag_mod/only-way.pbf" 24 | OUTFILE="./tag_mod/only-way.osm" 25 | osmosis --rbf $OSMFILE --tf reject-nodes --tf reject-relations --wx $OUTFILE 26 | 27 | grep " ./tag_mod/list_way.txt 28 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=6000) 8 | parameter (ny=6000) 9 | 10 | integer*1,allocatable :: inp(:,:), out(:,:) 11 | ! =============================================== 12 | call getarg(1,rfile) 13 | call getarg(2,wfile) 14 | 15 | allocate(inp(nx,ny),out(nx,ny)) 16 | 17 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 18 | read(11,rec=1) inp 19 | close(11) 20 | 21 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 22 | read(12,rec=1) out 23 | 24 | do iy=1, ny 25 | do ix=1, nx 26 | if( out(ix,iy)/=1 )then 27 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 28 | endif 29 | end do 30 | end do 31 | 32 | write(12,rec=1) out 33 | close(12) 34 | 35 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_river/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=6000) 8 | parameter (ny=6000) 9 | 10 | integer*1,allocatable :: inp(:,:), out(:,:) 11 | ! =============================================== 12 | call getarg(1,rfile) 13 | call getarg(2,wfile) 14 | 15 | allocate(inp(nx,ny),out(nx,ny)) 16 | 17 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 18 | read(11,rec=1) inp 19 | close(11) 20 | 21 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 22 | read(12,rec=1) out 23 | 24 | do iy=1, ny 25 | do ix=1, nx 26 | if( out(ix,iy)/=1 )then 27 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 28 | endif 29 | end do 30 | end do 31 | 32 | write(12,rec=1) out 33 | close(12) 34 | 35 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=6000) 8 | parameter (ny=6000) 9 | 10 | integer*1,allocatable :: inp(:,:), out(:,:) 11 | ! =============================================== 12 | call getarg(1,rfile) 13 | call getarg(2,wfile) 14 | 15 | allocate(inp(nx,ny),out(nx,ny)) 16 | 17 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 18 | read(11,rec=1) inp 19 | close(11) 20 | 21 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 22 | read(12,rec=1) out 23 | 24 | do iy=1, ny 25 | do ix=1, nx 26 | if( out(ix,iy)/=1 )then 27 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 28 | endif 29 | end do 30 | end do 31 | 32 | write(12,rec=1) out 33 | close(12) 34 | 35 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=6000) 8 | parameter (ny=6000) 9 | 10 | integer*1,allocatable :: inp(:,:), out(:,:) 11 | ! =============================================== 12 | call getarg(1,rfile) 13 | call getarg(2,wfile) 14 | 15 | allocate(inp(nx,ny),out(nx,ny)) 16 | 17 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 18 | read(11,rec=1) inp 19 | close(11) 20 | 21 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 22 | read(12,rec=1) out 23 | 24 | do iy=1, ny 25 | do ix=1, nx 26 | if( out(ix,iy)/=1 )then 27 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 28 | endif 29 | end do 30 | end do 31 | 32 | write(12,rec=1) out 33 | close(12) 34 | 35 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/s03-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | USER=`whoami` 4 | 5 | LON_ORI=-180 6 | LON_END=180 7 | LAT_ORI=-60 8 | LAT_END=90 9 | 10 | LON_ORI=$1 11 | LON_END=$2 12 | LAT_ORI=$3 13 | LAT_END=$4 14 | 15 | BASE=`pwd` 16 | 17 | mkdir -p tif 18 | 19 | #################################### 20 | 21 | SOUTH=$LAT_ORI 22 | while [ $SOUTH -lt $LAT_END ]; 23 | do 24 | WEST=$LON_ORI 25 | while [ $WEST -lt $LON_END ]; 26 | do 27 | CNAME=`./src/set_name $WEST $SOUTH` 28 | if [ -f ./5deg/${CNAME}.bil ]; then 29 | 30 | IFILE="./5deg/${CNAME}.bil" 31 | OFILE="./tif/${CNAME}.tif" 32 | PROJ="-s_srs EPSG:4326 -t_srs EPSG:4326" 33 | COMP="-co compress=deflate" 34 | rm -f $OFILE 35 | gdalwarp $PROJ $COMP $IFILE $OFILE & 36 | 37 | NUM=`ps aux | grep $USER | grep gdalwarp | wc -l | awk '{print $1}'` 38 | while [ $NUM -gt 16 ]; 39 | do 40 | sleep 2 41 | NUM=`ps aux | grep $USER | grep gdalwarp | wc -l | awk '{print $1}'` 42 | done 43 | 44 | fi 45 | WEST=$(( $WEST + 5 )) 46 | done 47 | SOUTH=$(( $SOUTH + 5 )) 48 | done 49 | wait 50 | 51 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/s04-jpg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | USER=`whoami` 3 | 4 | #link base topography data 5 | ln -sf ~yamadai/work/data/DEM/MERIT_DEM/v11 MERIT_DEM 6 | ln -sf ~yamadai/work/data/WaterMask/G3WBM/5deg G3WBM 7 | 8 | LON_ORI=-180 9 | LON_END=180 10 | LAT_ORI=-60 11 | LAT_END=90 12 | 13 | LON_ORI=$1 14 | LON_END=$2 15 | LAT_ORI=$3 16 | LAT_END=$4 17 | 18 | #################################### 19 | 20 | mkdir -p fig 21 | 22 | SOUTH=${LAT_ORI} 23 | NORTH=`expr $SOUTH + 5` 24 | while [ $SOUTH -lt ${LAT_END} ]; 25 | do 26 | WEST=${LON_ORI} 27 | EAST=`expr $WEST + 5` 28 | while [ $WEST -lt ${LON_END} ]; 29 | do 30 | CNAME=`./src/set_name $WEST $SOUTH` 31 | if [ -f ./MERIT_DEM/${CNAME}.bin ]; then 32 | ./t04-draw.sh $WEST $SOUTH & 33 | 34 | NUM=`ps aux | grep $USER | grep ./t04-draw.sh | wc -l | awk '{print $1}'` 35 | while [ $NUM -gt 8 ]; 36 | do 37 | sleep 1 38 | NUM=`ps aux | grep $USER | grep ./t04-draw.sh | wc -l | awk '{print $1}'` 39 | done 40 | 41 | fi 42 | WEST=`expr $WEST + 5` 43 | EAST=`expr $WEST + 5` 44 | done 45 | SOUTH=`expr $SOUTH + 5` 46 | NORTH=`expr $SOUTH + 5` 47 | done 48 | wait 49 | 50 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/set_bounds.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | character*6 :: w1, e1, s1, n1 8 | 9 | real :: hres 10 | parameter (hres=1./1200.*0.5) 11 | ! =============================================== 12 | call getarg(1,buf) 13 | read(buf,*) w0 14 | call getarg(2,buf) 15 | read(buf,*) e0 16 | call getarg(3,buf) 17 | read(buf,*) s0 18 | call getarg(4,buf) 19 | read(buf,*) n0 20 | 21 | w0=w0-0.1 22 | e0=e0+0.1 23 | s0=s0-0.1 24 | n0=n0+0.1 25 | 26 | write(w1,'(f6.1)') w0 27 | write(e1,'(f6.1)') e0 28 | write(s1,'(f6.1)') s0 29 | write(n1,'(f6.1)') n0 30 | 31 | w1=adjustl(w1) 32 | e1=adjustl(e1) 33 | s1=adjustl(s1) 34 | n1=adjustl(n1) 35 | 36 | buf='left='//trim(w1)//' right='//trim(e1)//' top='//trim(n1)//' bottom='//trim(s1) 37 | print *, trim(buf) 38 | 39 | !BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 40 | 41 | 42 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/set_bounds.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: buf 5 | real :: w0, e0, s0, n0 6 | 7 | character*6 :: w1, e1, s1, n1 8 | 9 | real :: hres 10 | parameter (hres=1./1200.*0.5) 11 | ! =============================================== 12 | call getarg(1,buf) 13 | read(buf,*) w0 14 | call getarg(2,buf) 15 | read(buf,*) e0 16 | call getarg(3,buf) 17 | read(buf,*) s0 18 | call getarg(4,buf) 19 | read(buf,*) n0 20 | 21 | w0=w0-0.1 22 | e0=e0+0.1 23 | s0=s0-0.1 24 | n0=n0+0.1 25 | 26 | write(w1,'(f6.1)') w0 27 | write(e1,'(f6.1)') e0 28 | write(s1,'(f6.1)') s0 29 | write(n1,'(f6.1)') n0 30 | 31 | w1=adjustl(w1) 32 | e1=adjustl(e1) 33 | s1=adjustl(s1) 34 | n1=adjustl(n1) 35 | 36 | buf='left='//trim(w1)//' right='//trim(e1)//' top='//trim(n1)//' bottom='//trim(s1) 37 | print *, trim(buf) 38 | 39 | !BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 40 | 41 | 42 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/t05-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON=$1 4 | LAT=$2 5 | CNAME=`./src/set_name $LON $LAT` 6 | WINDOW=`./src/set_window $LON $LAT` 7 | 8 | ### Ocean Mask ### 9 | 10 | SHPFILE="./shp_coast/water_polygons.shp" 11 | LAYER="water_polygons" 12 | WATFILE="${CNAME}.bil" 13 | rm -f ${CNAME}.bil 14 | 15 | echo $WATFILE 16 | 17 | if [ -f ./coast/${CNAME}_sea.bil ]; then 18 | cp ./coast/${CNAME}_sea.bil $WATFILE 19 | else 20 | gdal_rasterize -of EHdr -ot Byte -burn 1 -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $WATFILE 21 | fi 22 | 23 | ################### 24 | 25 | VARS="lines multipolygons" 26 | for VAR in $VARS 27 | do 28 | if [ $VAR = lines ]; then 29 | FILL=2 30 | else 31 | FILL=3 32 | fi 33 | 34 | SHPFILE="./shp/${CNAME}/${VAR}.shp" 35 | LAYER="$VAR" 36 | OUTFILE="tmp_${CNAME}.bil" 37 | if [ -f $SHPFILE ]; then 38 | echo $SHPFILE 39 | rm -f tmp_${CNAME}.* 40 | gdal_rasterize -of EHdr -ot Byte -burn $FILL -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 41 | ./src/marge_tmpfile $OUTFILE $WATFILE 42 | fi 43 | done 44 | 45 | ./src/wrte_ctl_5deg $LON $LAT ${CNAME}.bil ${CNAME}.ctl 46 | mv -f ${CNAME}.* 5deg 47 | rm -f tmp_${CNAME}.* 48 | 49 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/t05-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON=$1 4 | LAT=$2 5 | CNAME=`./src/set_name $LON $LAT` 6 | WINDOW=`./src/set_window $LON $LAT` 7 | 8 | ### Ocean Mask ### 9 | 10 | SHPFILE="./shp_coast/water_polygons.shp" 11 | LAYER="water_polygons" 12 | WATFILE="${CNAME}.bil" 13 | rm -f ${CNAME}.bil 14 | 15 | echo $WATFILE 16 | 17 | if [ -f ./coast/${CNAME}_sea.bil ]; then 18 | cp ./coast/${CNAME}_sea.bil $WATFILE 19 | else 20 | gdal_rasterize -of EHdr -ot Byte -burn 1 -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $WATFILE 21 | fi 22 | 23 | ################### 24 | 25 | VARS="lines multipolygons" 26 | for VAR in $VARS 27 | do 28 | if [ $VAR = lines ]; then 29 | FILL=2 30 | else 31 | FILL=3 32 | fi 33 | 34 | SHPFILE="./shp/${CNAME}/${VAR}.shp" 35 | LAYER="$VAR" 36 | OUTFILE="tmp_${CNAME}.bil" 37 | if [ -f $SHPFILE ]; then 38 | echo $SHPFILE 39 | rm -f tmp_${CNAME}.* 40 | gdal_rasterize -at -of EHdr -ot Byte -burn $FILL -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 41 | ./src/marge_tmpfile $OUTFILE $WATFILE 42 | fi 43 | done 44 | 45 | ./src/wrte_ctl_5deg $LON $LAT ${CNAME}.bil ${CNAME}.ctl 46 | mv -f ${CNAME}.* 5deg 47 | rm -f tmp_${CNAME}.* 48 | 49 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/t05-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON=$1 4 | LAT=$2 5 | CNAME=`./src/set_name $LON $LAT` 6 | WINDOW=`./src/set_window $LON $LAT` 7 | 8 | ### Ocean Mask ### 9 | 10 | SHPFILE="./shp_coast/water_polygons.shp" 11 | LAYER="water_polygons" 12 | WATFILE="${CNAME}.bil" 13 | rm -f ${CNAME}.bil 14 | 15 | echo $WATFILE 16 | 17 | if [ -f ./coast/${CNAME}_sea.bil ]; then 18 | cp ./coast/${CNAME}_sea.bil $WATFILE 19 | else 20 | gdal_rasterize -of EHdr -ot Byte -burn 1 -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $WATFILE 21 | fi 22 | 23 | ################### 24 | 25 | VARS="lines multipolygons" 26 | for VAR in $VARS 27 | do 28 | if [ $VAR = lines ]; then 29 | FILL=2 30 | else 31 | FILL=3 32 | fi 33 | 34 | SHPFILE="./shp/${CNAME}/${VAR}.shp" 35 | LAYER="$VAR" 36 | OUTFILE="tmp_${CNAME}.bil" 37 | if [ -f $SHPFILE ]; then 38 | echo $SHPFILE 39 | rm -f tmp_${CNAME}.* 40 | gdal_rasterize -of EHdr -ot Byte -burn $FILL -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 41 | ./src/marge_tmpfile $OUTFILE $WATFILE 42 | fi 43 | done 44 | 45 | ./src/wrte_ctl_5deg $LON $LAT ${CNAME}.bil ${CNAME}.ctl 46 | mv -f ${CNAME}.* 5deg 47 | rm -f tmp_${CNAME}.* 48 | 49 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/t05-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LON=$1 4 | LAT=$2 5 | CNAME=`./src/set_name $LON $LAT` 6 | WINDOW=`./src/set_window $LON $LAT` 7 | 8 | ### Ocean Mask ### 9 | 10 | SHPFILE="./shp_coast/water_polygons.shp" 11 | LAYER="water_polygons" 12 | WATFILE="${CNAME}.bil" 13 | rm -f ${CNAME}.bil 14 | 15 | echo $WATFILE 16 | 17 | if [ -f ./coast/${CNAME}_sea.bil ]; then 18 | cp ./coast/${CNAME}_sea.bil $WATFILE 19 | else 20 | gdal_rasterize -of EHdr -ot Byte -burn 1 -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $WATFILE 21 | fi 22 | 23 | ################### 24 | 25 | VARS="lines multipolygons" 26 | for VAR in $VARS 27 | do 28 | if [ $VAR = lines ]; then 29 | FILL="2" 30 | else 31 | FILL="3" 32 | fi 33 | 34 | SHPFILE="./shp/${CNAME}/${VAR}.shp" 35 | LAYER="$VAR" 36 | OUTFILE="tmp_${CNAME}.bil" 37 | if [ -f $SHPFILE ]; then 38 | echo $SHPFILE 39 | rm -f tmp_${CNAME}.* 40 | gdal_rasterize $TOUCH -of EHdr -ot Byte -burn $FILL -tr 0.00083333333333 0.00083333333333 -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 41 | ./src/marge_tmpfile $OUTFILE $WATFILE 42 | fi 43 | done 44 | 45 | ./src/wrte_ctl_5deg $LON $LAT ${CNAME}.bil ${CNAME}.ctl 46 | mv -f ${CNAME}.* 5deg 47 | rm -f tmp_${CNAME}.* 48 | 49 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/t01-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | SOUTH=$2 5 | CNAME5=`./src/set_name $WEST $SOUTH` 6 | 7 | EAST=$(( $WEST + 5 )) 8 | NORTH=$(( SOUTH + 5 )) 9 | 10 | RESOL="0.0000925925925 0.0000925925925" 11 | 12 | LAT=$SOUTH 13 | while [ $LAT -lt $NORTH ]; 14 | do 15 | LON=$WEST 16 | while [ $LON -lt $EAST ]; 17 | do 18 | CNAME1=`./src/set_name $LON $LAT` 19 | WINDOW=`./src/set_window $LON $LAT` 20 | echo $CNAME1 $WINDOW 21 | 22 | WATFILE="${CNAME1}.bil" 23 | 24 | VARS="lines multipolygons" 25 | for VAR in $VARS 26 | do 27 | if [ $VAR = lines ]; then 28 | FILL="2" 29 | else 30 | FILL="3" 31 | fi 32 | 33 | SHPFILE="./shp/${CNAME5}/${VAR}.shp" 34 | LAYER="$VAR" 35 | OUTFILE="tmp_${CNAME1}.bil" 36 | if [ -f $SHPFILE ]; then 37 | echo $SHPFILE 38 | rm -f tmp_${CNAME1}.* 39 | gdal_rasterize $TOUCH -of EHdr -ot Byte -burn $FILL -tr $RESOL -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 40 | ./src/marge_tmpfile $OUTFILE $WATFILE 41 | fi 42 | done 43 | 44 | ./src/wrte_ctl_10m $LON $LAT ${CNAME1}.bil ${CNAME1}.ctl 45 | mv -f ${CNAME1}.* 1deg_10m 46 | rm -f tmp_${CNAME1}.* 47 | 48 | LON=$(( $LON + 1 )) 49 | done 50 | LAT=$(( $LAT + 1 )) 51 | done 52 | 53 | exit 54 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/t01-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | SOUTH=$2 5 | CNAME5=`./src/set_name $WEST $SOUTH` 6 | 7 | EAST=$(( $WEST + 5 )) 8 | NORTH=$(( SOUTH + 5 )) 9 | 10 | RESOL="0.0000925925925 0.0000925925925" 11 | 12 | LAT=$SOUTH 13 | while [ $LAT -lt $NORTH ]; 14 | do 15 | LON=$WEST 16 | while [ $LON -lt $EAST ]; 17 | do 18 | CNAME1=`./src/set_name $LON $LAT` 19 | WINDOW=`./src/set_window $LON $LAT` 20 | echo $CNAME1 $WINDOW 21 | 22 | WATFILE="${CNAME1}.bil" 23 | 24 | VARS="lines multipolygons" 25 | for VAR in $VARS 26 | do 27 | if [ $VAR = lines ]; then 28 | FILL="2" 29 | else 30 | FILL="3" 31 | fi 32 | 33 | SHPFILE="./shp/${CNAME5}/${VAR}.shp" 34 | LAYER="$VAR" 35 | OUTFILE="tmp_${CNAME1}.bil" 36 | if [ -f $SHPFILE ]; then 37 | echo $SHPFILE 38 | rm -f tmp_${CNAME1}.* 39 | gdal_rasterize $TOUCH -of EHdr -ot Byte -burn $FILL -tr $RESOL -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 40 | ./src/marge_tmpfile $OUTFILE $WATFILE 41 | fi 42 | done 43 | 44 | ./src/wrte_ctl_10m $LON $LAT ${CNAME1}.bil ${CNAME1}.ctl 45 | mv -f ${CNAME1}.* 1deg_10m 46 | rm -f tmp_${CNAME1}.* 47 | 48 | LON=$(( $LON + 1 )) 49 | done 50 | LAT=$(( $LAT + 1 )) 51 | done 52 | 53 | exit 54 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/t01-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | SOUTH=$2 5 | CNAME5=`./src/set_name $WEST $SOUTH` 6 | 7 | EAST=$(( $WEST + 5 )) 8 | NORTH=$(( SOUTH + 5 )) 9 | 10 | RESOL="0.0000925925925 0.0000925925925" 11 | 12 | LAT=$SOUTH 13 | while [ $LAT -lt $NORTH ]; 14 | do 15 | LON=$WEST 16 | while [ $LON -lt $EAST ]; 17 | do 18 | CNAME1=`./src/set_name $LON $LAT` 19 | WINDOW=`./src/set_window $LON $LAT` 20 | echo $CNAME1 $WINDOW 21 | 22 | WATFILE="${CNAME1}.bil" 23 | 24 | VARS="lines multipolygons" 25 | for VAR in $VARS 26 | do 27 | if [ $VAR = lines ]; then 28 | FILL="2" 29 | else 30 | FILL="3" 31 | fi 32 | 33 | SHPFILE="./shp/${CNAME5}/${VAR}.shp" 34 | LAYER="$VAR" 35 | OUTFILE="tmp_${CNAME1}.bil" 36 | if [ -f $SHPFILE ]; then 37 | echo $SHPFILE 38 | rm -f tmp_${CNAME1}.* 39 | gdal_rasterize $TOUCH -of EHdr -ot Byte -burn $FILL -tr $RESOL -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 40 | ./src/marge_tmpfile $OUTFILE $WATFILE 41 | fi 42 | done 43 | 44 | ./src/wrte_ctl_10m $LON $LAT ${CNAME1}.bil ${CNAME1}.ctl 45 | mv -f ${CNAME1}.* 1deg_10m 46 | rm -f tmp_${CNAME1}.* 47 | 48 | LON=$(( $LON + 1 )) 49 | done 50 | LAT=$(( $LAT + 1 )) 51 | done 52 | 53 | exit 54 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/t01-gdal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WEST=$1 4 | SOUTH=$2 5 | CNAME5=`./src/set_name $WEST $SOUTH` 6 | 7 | EAST=$(( $WEST + 5 )) 8 | NORTH=$(( SOUTH + 5 )) 9 | 10 | RESOL="0.0000925925925 0.0000925925925" 11 | 12 | LAT=$SOUTH 13 | while [ $LAT -lt $NORTH ]; 14 | do 15 | LON=$WEST 16 | while [ $LON -lt $EAST ]; 17 | do 18 | CNAME1=`./src/set_name $LON $LAT` 19 | WINDOW=`./src/set_window $LON $LAT` 20 | echo $CNAME1 $WINDOW 21 | 22 | WATFILE="${CNAME1}.bil" 23 | 24 | VARS="lines multipolygons" 25 | for VAR in $VARS 26 | do 27 | if [ $VAR = lines ]; then 28 | FILL="2" 29 | else 30 | FILL="3" 31 | fi 32 | 33 | SHPFILE="./shp/${CNAME5}/${VAR}.shp" 34 | LAYER="$VAR" 35 | OUTFILE="tmp_${CNAME1}.bil" 36 | if [ -f $SHPFILE ]; then 37 | echo $SHPFILE 38 | rm -f tmp_${CNAME1}.* 39 | gdal_rasterize $TOUCH -of EHdr -ot Byte -burn $FILL -tr $RESOL -te $WINDOW -l $LAYER $SHPFILE $OUTFILE 40 | ./src/marge_tmpfile $OUTFILE $WATFILE 41 | fi 42 | done 43 | 44 | ./src/wrte_ctl_10m $LON $LAT ${CNAME1}.bil ${CNAME1}.ctl 45 | mv -f ${CNAME1}.* 1deg_10m 46 | rm -f tmp_${CNAME1}.* 47 | 48 | LON=$(( $LON + 1 )) 49 | done 50 | LAT=$(( $LAT + 1 )) 51 | done 52 | 53 | exit 54 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s04-osm2shp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OPTIONS='-overwrite --config OSM_CONFIG_FILE ./osmconf_water.ini -skipfailures ' 3 | mkdir -p shp 4 | mkdir -p ./osm/lonlat-tmp 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | LON_ORI=$1 12 | LON_END=$2 13 | LAT_ORI=$3 14 | LAT_END=$4 15 | 16 | 17 | WEST=${LON_ORI} 18 | while [ $WEST -lt ${LON_END} ]; 19 | do 20 | EAST=`expr $WEST + 5` 21 | 22 | SOUTH=${LAT_ORI} 23 | while [ $SOUTH -lt $LAT_END ]; 24 | do 25 | NORTH=`expr $SOUTH + 5` 26 | 27 | CNAME=`./src/set_name $WEST $SOUTH` 28 | OSMFILE="./osm/lonlat/${CNAME}-water.osm" 29 | TMPFILE="./osm/lonlat-tmp/${CNAME}-water.osm" 30 | 31 | osmosis --rx $OSMFILE --tf reject-ways tunnel=yes --wx tmp.osm 32 | mv -f tmp.osm $OSMFILE 33 | 34 | SHPDIR="./shp/${CNAME}" 35 | mkdir -p $SHPDIR 36 | 37 | WATTAG='' 38 | RESTAG='' 39 | 40 | cat $OSMFILE | sed -e "s#${WATTAG}#TTWAT#" | grep -v ' $TMPFILE 41 | ogr2ogr $OPTIONS -f "ESRI Shapefile" $SHPDIR $TMPFILE 42 | 43 | 44 | SOUTH=`expr $SOUTH + 5` 45 | done 46 | wait 47 | WEST=`expr $WEST + 5` 48 | done 49 | wait 50 | -------------------------------------------------------------------------------- /hires_2021Feb/ReadMe.md: -------------------------------------------------------------------------------- 1 | # OSM water layer scripts (HighRes) 2 | Script to generate higher resolution data, using calc_2021Feb intermediate data. 3 | 4 | ### [1] Pre-processing 5 | Complete OSM PBF -> Shapefile conversion in calc_2021Feb project. 6 | 7 | ### [2] Extract water 8 | Extract major water body from planet.osm, procedure is same as calc_2021Feb/ project. 9 | 1. Goto **extract_water/** directory, edit **auto.sh**, and execute scriptes. 10 | 2. Goto **add_river/, add_canal/, add_stream/** directories, **auto.sh**. and execute scriptes. 11 | 3. Goto **merge_water/** directory, and execute scriptes.edit **auto.sh**, 12 | 13 | ### [3] Hires water map output 14 | 10m resolution: **merge_water/1deg_10m/** 15 | 30m resolution: **merge_water/1deg_30m/** !! upscaled map 16 | 17 | #### Water classification in rasterlized data 18 | 19 | [High resolution data: 1deg_10m/] 20 | **10m resolution product** 21 | Below values are used in rasterlized data. 22 | 0: land 23 | 1: ocean 24 | 2: large water body (poligon) 25 | 3: majopr river 26 | 4: canal 27 | 5: small stream 28 | 29 | [High resolution data: 1deg_30m/] 30 | **30m resolution upscaled product** 31 | 10-100: fraction of water treated as polygon 32 | 5: water tagged as river (line, without area) 33 | 2: water tagged as canal (line, without area) 34 | 1: water tagged as stream (line, without area) 35 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s04-osm2shp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OPTIONS='-overwrite --config OSM_CONFIG_FILE ./osmconf_water.ini -skipfailures ' 3 | mkdir -p shp 4 | mkdir -p ./osm/lonlat-tmp 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | LON_ORI=$1 12 | LON_END=$2 13 | LAT_ORI=$3 14 | LAT_END=$4 15 | 16 | 17 | WEST=${LON_ORI} 18 | while [ $WEST -lt ${LON_END} ]; 19 | do 20 | EAST=`expr $WEST + 5` 21 | 22 | SOUTH=${LAT_ORI} 23 | while [ $SOUTH -lt $LAT_END ]; 24 | do 25 | NORTH=`expr $SOUTH + 5` 26 | 27 | CNAME=`./src/set_name $WEST $SOUTH` 28 | OSMFILE="./osm/lonlat/${CNAME}-water.osm" 29 | TMPFILE="./osm/lonlat-tmp/${CNAME}-water.osm" 30 | 31 | osmosis --rx $OSMFILE --tf reject-ways tunnel=yes --wx tmp.osm 32 | mv -f tmp.osm $OSMFILE 33 | 34 | SHPDIR="./shp/${CNAME}" 35 | mkdir -p $SHPDIR 36 | 37 | WATTAG='' 38 | RESTAG='' 39 | 40 | cat $OSMFILE | sed -e "s#${WATTAG}#TTWAT#" | grep -v ' $TMPFILE 41 | ogr2ogr $OPTIONS -f "ESRI Shapefile" $SHPDIR $TMPFILE 42 | 43 | SOUTH=`expr $SOUTH + 5` 44 | done 45 | WEST=`expr $WEST + 5` 46 | done 47 | wait 48 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | integer :: ios 6 | 7 | integer :: ix, iy, nx, ny 8 | parameter (nx=10800) 9 | parameter (ny=10800) 10 | 11 | integer*1,allocatable :: inp(:,:), out(:,:) 12 | ! =============================================== 13 | call getarg(1,rfile) 14 | call getarg(2,wfile) 15 | 16 | allocate(inp(nx,ny),out(nx,ny)) 17 | 18 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 19 | if( ios/=0 ) stop 20 | read(11,rec=1) inp 21 | close(11) 22 | 23 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 24 | if( ios==0 )then 25 | read(12,rec=1) out 26 | else 27 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='new') 28 | out(:,:)=0 29 | endif 30 | 31 | do iy=1, ny 32 | do ix=1, nx 33 | if( out(ix,iy)/=1 )then 34 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 35 | endif 36 | end do 37 | end do 38 | 39 | write(12,rec=1) out 40 | close(12) 41 | 42 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | integer :: ios 6 | 7 | integer :: ix, iy, nx, ny 8 | parameter (nx=10800) 9 | parameter (ny=10800) 10 | 11 | integer*1,allocatable :: inp(:,:), out(:,:) 12 | ! =============================================== 13 | call getarg(1,rfile) 14 | call getarg(2,wfile) 15 | 16 | allocate(inp(nx,ny),out(nx,ny)) 17 | 18 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 19 | if( ios/=0 ) stop 20 | read(11,rec=1) inp 21 | close(11) 22 | 23 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 24 | if( ios==0 )then 25 | read(12,rec=1) out 26 | else 27 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='new') 28 | out(:,:)=0 29 | endif 30 | 31 | do iy=1, ny 32 | do ix=1, nx 33 | if( out(ix,iy)/=1 )then 34 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 35 | endif 36 | end do 37 | end do 38 | 39 | write(12,rec=1) out 40 | close(12) 41 | 42 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | integer :: ios 6 | 7 | integer :: ix, iy, nx, ny 8 | parameter (nx=10800) 9 | parameter (ny=10800) 10 | 11 | integer*1,allocatable :: inp(:,:), out(:,:) 12 | ! =============================================== 13 | call getarg(1,rfile) 14 | call getarg(2,wfile) 15 | 16 | allocate(inp(nx,ny),out(nx,ny)) 17 | 18 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 19 | if( ios/=0 ) stop 20 | read(11,rec=1) inp 21 | close(11) 22 | 23 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 24 | if( ios==0 )then 25 | read(12,rec=1) out 26 | else 27 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='new') 28 | out(:,:)=0 29 | endif 30 | 31 | do iy=1, ny 32 | do ix=1, nx 33 | if( out(ix,iy)/=1 )then 34 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 35 | endif 36 | end do 37 | end do 38 | 39 | write(12,rec=1) out 40 | close(12) 41 | 42 | end program check_area -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/marge_tmpfile.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | integer :: ios 6 | 7 | integer :: ix, iy, nx, ny 8 | parameter (nx=10800) 9 | parameter (ny=10800) 10 | 11 | integer*1,allocatable :: inp(:,:), out(:,:) 12 | ! =============================================== 13 | call getarg(1,rfile) 14 | call getarg(2,wfile) 15 | 16 | allocate(inp(nx,ny),out(nx,ny)) 17 | 18 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 19 | if( ios/=0 ) stop 20 | read(11,rec=1) inp 21 | close(11) 22 | 23 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 24 | if( ios==0 )then 25 | read(12,rec=1) out 26 | else 27 | open(12,file=wfile,form='unformatted',access='direct',recl=1*nx*ny,status='new') 28 | out(:,:)=0 29 | endif 30 | 31 | do iy=1, ny 32 | do ix=1, nx 33 | if( out(ix,iy)/=1 )then 34 | out(ix,iy)=max(out(ix,iy),inp(ix,iy)) 35 | endif 36 | end do 37 | end do 38 | 39 | write(12,rec=1) out 40 | close(12) 41 | 42 | end program check_area -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s02-divide_lons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/devide 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | SOUTH=-90 9 | NORTH=90 10 | 11 | WEST=${LON_ORI} 12 | while [ $WEST -lt ${LON_END} ]; 13 | do 14 | EAST=`expr $WEST + 30` 15 | 16 | OSMFILE="./osm/bank/planet-all.osm.pbf" 17 | CNAME=`./src/set_name $WEST 0` 18 | OUTFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 19 | 20 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 21 | BBOPT="completeWays=yes completeRelations=yes" 22 | 23 | echo $OUTFILE 24 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 25 | 26 | WEST=`expr $WEST + 30` 27 | done 28 | wait 29 | 30 | 31 | 32 | WEST=${LON_ORI} 33 | while [ $WEST -lt ${LON_END} ]; 34 | do 35 | EAST=`expr $WEST + 30` 36 | 37 | CNAME=`./src/set_name $WEST 0` 38 | OSMFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 39 | 40 | WEST2=$WEST 41 | while [ $WEST2 -lt $EAST ]; 42 | do 43 | EAST2=`expr $WEST2 + 5` 44 | 45 | CNAME=`./src/set_name $WEST2 0` 46 | OUTFILE="./osm/devide/${CNAME}-lon5.osm.pbf" 47 | 48 | BOUND="left=${WEST2} right=${EAST2} top=${NORTH} bottom=${SOUTH}" 49 | BBOPT="completeWays=yes completeRelations=yes" 50 | 51 | echo $OUTFILE 52 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 53 | WEST2=`expr $WEST2 + 5` 54 | done 55 | wait 56 | WEST=`expr $WEST + 30` 57 | done 58 | wait 59 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s04-osm2shp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | OPTIONS='-overwrite --config OSM_CONFIG_FILE ./osmconf_water.ini -skipfailures ' 5 | mkdir -p shp 6 | mkdir -p ./osm/lonlat-tmp 7 | 8 | LON_ORI=-180 9 | LON_END=180 10 | LAT_ORI=-60 11 | LAT_END=90 12 | 13 | LON_ORI=$1 14 | LON_END=$2 15 | LAT_ORI=$3 16 | LAT_END=$4 17 | 18 | 19 | WEST=${LON_ORI} 20 | while [ $WEST -lt ${LON_END} ]; 21 | do 22 | EAST=`expr $WEST + 5` 23 | 24 | SOUTH=${LAT_ORI} 25 | while [ $SOUTH -lt $LAT_END ]; 26 | do 27 | NORTH=`expr $SOUTH + 5` 28 | 29 | CNAME=`./src/set_name $WEST $SOUTH` 30 | OSMFILE="./osm/lonlat/${CNAME}-water.osm" 31 | TMPFILE="./osm/lonlat-tmp/${CNAME}-water.osm" 32 | 33 | osmosis --rx $OSMFILE --tf reject-ways tunnel=yes --wx tmp.osm 34 | mv -f tmp.osm $OSMFILE 35 | 36 | SHPDIR="./shp/${CNAME}" 37 | mkdir -p $SHPDIR 38 | 39 | WATTAG='' 40 | RESTAG='' 41 | 42 | cat $OSMFILE | sed -e "s#${WATTAG}#TTWAT#" | grep -v ' $TMPFILE 43 | ogr2ogr $OPTIONS -f "ESRI Shapefile" $SHPDIR $TMPFILE & 44 | 45 | 46 | SOUTH=`expr $SOUTH + 5` 47 | done 48 | wait 49 | WEST=`expr $WEST + 5` 50 | done 51 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s02-divide_lons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/devide 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | SOUTH=-90 9 | NORTH=90 10 | 11 | 12 | 13 | WEST=${LON_ORI} 14 | while [ $WEST -lt ${LON_END} ]; 15 | do 16 | EAST=`expr $WEST + 30` 17 | 18 | OSMFILE="./osm/canal/planet-all.osm.pbf" 19 | CNAME=`./src/set_name $WEST 0` 20 | OUTFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 21 | 22 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 23 | BBOPT="completeWays=yes completeRelations=yes" 24 | 25 | echo $OUTFILE 26 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 27 | 28 | WEST=`expr $WEST + 30` 29 | done 30 | wait 31 | 32 | 33 | 34 | WEST=${LON_ORI} 35 | while [ $WEST -lt ${LON_END} ]; 36 | do 37 | EAST=`expr $WEST + 30` 38 | 39 | CNAME=`./src/set_name $WEST 0` 40 | OSMFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 41 | 42 | WEST2=$WEST 43 | while [ $WEST2 -lt $EAST ]; 44 | do 45 | EAST2=`expr $WEST2 + 5` 46 | 47 | CNAME=`./src/set_name $WEST2 0` 48 | OUTFILE="./osm/devide/${CNAME}-lon5.osm.pbf" 49 | 50 | BOUND="left=${WEST2} right=${EAST2} top=${NORTH} bottom=${SOUTH}" 51 | BBOPT="completeWays=yes completeRelations=yes" 52 | 53 | echo $OUTFILE 54 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 55 | WEST2=`expr $WEST2 + 5` 56 | done 57 | wait 58 | WEST=`expr $WEST + 30` 59 | done 60 | wait 61 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s02-divide_lons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/devide 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | SOUTH=-90 9 | NORTH=90 10 | 11 | 12 | 13 | WEST=${LON_ORI} 14 | while [ $WEST -lt ${LON_END} ]; 15 | do 16 | EAST=`expr $WEST + 30` 17 | 18 | OSMFILE="./osm/stream/planet-all.osm.pbf" 19 | CNAME=`./src/set_name $WEST 0` 20 | OUTFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 21 | 22 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 23 | BBOPT="completeWays=yes completeRelations=yes" 24 | 25 | echo $OUTFILE 26 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 27 | 28 | WEST=`expr $WEST + 30` 29 | done 30 | wait 31 | 32 | 33 | 34 | WEST=${LON_ORI} 35 | while [ $WEST -lt ${LON_END} ]; 36 | do 37 | EAST=`expr $WEST + 30` 38 | 39 | CNAME=`./src/set_name $WEST 0` 40 | OSMFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 41 | 42 | WEST2=$WEST 43 | while [ $WEST2 -lt $EAST ]; 44 | do 45 | EAST2=`expr $WEST2 + 5` 46 | 47 | CNAME=`./src/set_name $WEST2 0` 48 | OUTFILE="./osm/devide/${CNAME}-lon5.osm.pbf" 49 | 50 | BOUND="left=${WEST2} right=${EAST2} top=${NORTH} bottom=${SOUTH}" 51 | BBOPT="completeWays=yes completeRelations=yes" 52 | 53 | echo $OUTFILE 54 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 55 | WEST2=`expr $WEST2 + 5` 56 | done 57 | wait 58 | WEST=`expr $WEST + 30` 59 | done 60 | wait 61 | -------------------------------------------------------------------------------- /OSM_sea/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/wrte_ctl_5deg.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | open(21,file=ctlfile,form='formatted') 21 | write(21,'(a6,a)' ) 'dset ^', binfile 22 | write(21,'(a)') 'undef 0' 23 | write(21,'(a)') 'title DFO_MODIS' 24 | write(21,'(a)') 'options yrev little_endian' 25 | write(21,'(a5,i4,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0008333333333' 26 | write(21,'(a5,i4,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0008333333333' 27 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 28 | write(21,'(a)') 'zdef 1 linear 1 1' 29 | write(21,'(a)') 'vars 1' 30 | write(21,'(a)') 'var 1 -1,40,1 **' 31 | write(21,'(a)') 'ENDVARS' 32 | close(21) 33 | 34 | end program wrte_ctl 35 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s02-divide_lons.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | mkdir -p ./osm/devide 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | SOUTH=-90 9 | NORTH=90 10 | 11 | 12 | 13 | WEST=${LON_ORI} 14 | while [ $WEST -lt ${LON_END} ]; 15 | do 16 | EAST=`expr $WEST + 30` 17 | 18 | OSMFILE="./osm/water/planet-all.osm.pbf" 19 | CNAME=`./src/set_name $WEST 0` 20 | OUTFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 21 | 22 | # BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 23 | BOUND=`./src/set_bounds $WEST $EAST $SOUTH $NORTH` 24 | BBOPT="completeWays=yes completeRelations=yes" 25 | 26 | echo $OUTFILE 27 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 28 | 29 | WEST=`expr $WEST + 30` 30 | done 31 | wait 32 | 33 | 34 | WEST=${LON_ORI} 35 | while [ $WEST -lt ${LON_END} ]; 36 | do 37 | EAST=`expr $WEST + 30` 38 | 39 | CNAME=`./src/set_name $WEST 0` 40 | OSMFILE="./osm/devide/${CNAME}-lon30.osm.pbf" 41 | 42 | WEST2=$WEST 43 | while [ $WEST2 -lt $EAST ]; 44 | do 45 | EAST2=`expr $WEST2 + 5` 46 | 47 | CNAME=`./src/set_name $WEST2 0` 48 | OUTFILE="./osm/devide/${CNAME}-lon5.osm.pbf" 49 | 50 | # BOUND="left=${WEST2} right=${EAST2} top=${NORTH} bottom=${SOUTH}" 51 | BOUND=`./src/set_bounds $WEST2 $EAST2 $SOUTH $NORTH ` 52 | BBOPT="completeWays=yes completeRelations=yes" 53 | 54 | echo $OUTFILE 55 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 56 | WEST2=`expr $WEST2 + 5` 57 | done 58 | wait 59 | WEST=`expr $WEST + 30` 60 | done -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/u01-notag_relations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | mkdir -p java.tmp 5 | mkdir -p tag_mod 6 | 7 | ### extract waterway & natural-water, relations and ways 8 | 9 | OSMFILE="./osm/planet.osm.pbf" 10 | OUTFILE="./tag_mod/only-relation.osm" 11 | osmosis --rbf $OSMFILE --tf reject-ways --tf reject-nodes --wx $OUTFILE 12 | 13 | OSMFILE="./tag_mod/only-relation.osm" 14 | OUTFILE="./tag_mod/notag-relation.osm" 15 | osmosis --fast-read-xml $OSMFILE --tf accept-relations type=multipolygon --tf reject-relations natural=* --tf reject-relations waterway=* --tf reject-relations building=* --tf reject-relations landuse=* --tf reject-relations amenity=* --tf reject-relations highway=* --tf reject-relations boundary=* --tf reject-relations place=* --tf reject-relations aeroway=* --tf reject-relations tourism=* --tf reject-relations railway=* --tf reject-relations barrier=* --tf reject-relations shop=* --tf reject-relations wood=* --tf reject-relations FIXME=* --tf reject-relations fixme=* --tf reject-relations building:part=* --tf reject-relations area:highway=* --tf reject-relations leisure=* --wx $OUTFILE 16 | 17 | OSMFILE="./tag_mod/notag-relation.osm" 18 | 19 | # for additional edditing 20 | #osmosis --fast-read-xml $OSMFILE --tf reject-relations FIXME=* --wx tmp.osm 21 | #mv tmp.osm $OSMFILE 22 | 23 | grep " tmp1 26 | grep -v addr tmp1 | grep -v GeoBase > tmp.txt 27 | 28 | rm -f tmp1 29 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s04-osm2shp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | OPTIONS='-overwrite --config OSM_CONFIG_FILE ./osmconf_water.ini -skipfailures ' 3 | 4 | mkdir -p shp 5 | mkdir -p ./osm/lonlat-tmp 6 | 7 | LON_ORI=-180 8 | LON_END=180 9 | LAT_ORI=-60 10 | LAT_END=90 11 | 12 | LON_ORI=$1 13 | LON_END=$2 14 | LAT_ORI=$3 15 | LAT_END=$4 16 | 17 | 18 | WEST=${LON_ORI} 19 | while [ $WEST -lt ${LON_END} ]; 20 | do 21 | SOUTH=${LAT_ORI} 22 | while [ $SOUTH -lt $LAT_END ]; 23 | do 24 | CNAME=`./src/set_name $WEST $SOUTH` 25 | OSMFILE="./osm/lonlat/${CNAME}-water.osm" 26 | TMPFILE="./osm/lonlat-tmp/${CNAME}-water.osm" 27 | 28 | osmosis --rx $OSMFILE --tf reject-ways tunnel=yes --wx tmp.osm 29 | mv -f tmp.osm $OSMFILE 30 | 31 | WATTAG='' 32 | RESTAG='' 33 | cat $OSMFILE | sed -e "s#${WATTAG}#TTWAT#" | grep -v ' $TMPFILE & 34 | SOUTH=`expr $SOUTH + 5` 35 | done 36 | wait 37 | WEST=`expr $WEST + 5` 38 | done 39 | wait 40 | 41 | 42 | WEST=${LON_ORI} 43 | while [ $WEST -lt ${LON_END} ]; 44 | do 45 | SOUTH=${LAT_ORI} 46 | while [ $SOUTH -lt $LAT_END ]; 47 | do 48 | CNAME=`./src/set_name $WEST $SOUTH` 49 | TMPFILE="./osm/lonlat-tmp/${CNAME}-water.osm" 50 | 51 | SHPDIR="./shp/${CNAME}" 52 | mkdir -p $SHPDIR 53 | 54 | ogr2ogr $OPTIONS -f "ESRI Shapefile" $SHPDIR $TMPFILE & 55 | SOUTH=`expr $SOUTH + 5` 56 | done 57 | wait 58 | WEST=`expr $WEST + 5` 59 | done 60 | wait -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/wrte_ctl_30m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=3600) 7 | parameter (ny=3600) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./3600. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.000277777778' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.000277777778' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/wrte_ctl_30m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=3600) 7 | parameter (ny=3600) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./3600. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.000277777778' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.000277777778' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/wrte_ctl_30m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=3600) 7 | parameter (ny=3600) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./3600. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.000277777778' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.000277777778' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/wrte_ctl_30m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=3600) 7 | parameter (ny=3600) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./3600. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.000277777778' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.000277777778' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/wrte_ctl_10m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=10800) 7 | parameter (ny=10800) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./10800. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0000925925925' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0000925925925' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/wrte_ctl_10m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=10800) 7 | parameter (ny=10800) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./10800. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0000925925925' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0000925925925' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/wrte_ctl_10m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=10800) 7 | parameter (ny=10800) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./10800. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0000925925925' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0000925925925' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/wrte_ctl_30m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=3600) 7 | parameter (ny=3600) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./3600. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.000277777778' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.000277777778' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/wrte_ctl_10m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=10800) 7 | parameter (ny=10800) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./10800. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0000925925925' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0000925925925' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/wrte_ctl_10m.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=10800) 7 | parameter (ny=10800) 8 | real*8 :: lon, lat, csize 9 | character*128 :: buf 10 | ! file 11 | character*60 :: binfile, ctlfile 12 | ! =============================================== 13 | call getarg(1,buf) 14 | read(buf,*) lon 15 | call getarg(2,buf) 16 | read(buf,*) lat 17 | call getarg(3,binfile) 18 | call getarg(4,ctlfile) 19 | 20 | csize=1./10800. 21 | lon=lon+csize*0.5 22 | lat=lat+csize*0.5 23 | 24 | open(21,file=ctlfile,form='formatted') 25 | write(21,'(a6,a)' ) 'dset ^', binfile 26 | write(21,'(a)') 'undef 0' 27 | write(21,'(a)') 'title DFO_MODIS' 28 | write(21,'(a)') 'options yrev little_endian' 29 | write(21,'(a5,i6,a8,f22.16,a16)') 'xdef ', nx, ' linear ', lon, ' 0.0000925925925' 30 | write(21,'(a5,i6,a8,f22.16,a16)') 'ydef ', ny, ' linear ', lat, ' 0.0000925925925' 31 | write(21,'(a)') 'tdef 1 linear 00Z01jan2000 1yr' 32 | write(21,'(a)') 'zdef 1 linear 1 1' 33 | write(21,'(a)') 'vars 1' 34 | write(21,'(a)') 'var 1 -1,40,1 **' 35 | write(21,'(a)') 'ENDVARS' 36 | close(21) 37 | 38 | end program wrte_ctl 39 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/src/wrte_hdr_int1.f90: -------------------------------------------------------------------------------- 1 | program wrte_ctl 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: nx, ny 6 | parameter (nx=6000) 7 | parameter (ny=6000) 8 | real*8 :: lon, lat 9 | real*8 :: size 10 | character*128 :: buf 11 | ! file 12 | character*128 :: hdrfile 13 | character*15 :: nodata 14 | real*8 :: ULXMAP, ULYMAP 15 | ! =============================================== 16 | call getarg(1,buf) 17 | read(buf,*) lon 18 | call getarg(2,buf) 19 | read(buf,*) lat 20 | call getarg(3,hdrfile) 21 | 22 | size=dble(1.0)/dble(1200.) 23 | 24 | ULXMAP=lon 25 | ULYMAP=lat+5.-size 26 | 27 | open(21,file=hdrfile,form='formatted') 28 | write(21,'(a)' ) 'BYTEORDER I ' 29 | write(21,'(a)' ) 'LAYOUT BIL ' 30 | write(21,'(a)' ) 'NROWS 6000' 31 | write(21,'(a)' ) 'NCOLS 6000' 32 | write(21,'(a)' ) 'NBANDS 1 ' 33 | write(21,'(a)' ) 'NBITS 8 ' 34 | write(21,'(a)' ) 'BANDROWBYTES 6000' 35 | write(21,'(a)' ) 'TOTALROWBYTES 6000' 36 | write(21,'(a)' ) 'BANDGAPBYTES 0 ' 37 | write(21,'(a)' ) 'NODATA -9 ' 38 | write(21,'(a,f25.20)' ) 'ULXMAP ', ULXMAP 39 | write(21,'(a,f25.20)' ) 'ULYMAP ', ULYMAP 40 | write(21,'(a,f25.20)' ) 'XDIM ', size 41 | write(21,'(a,f25.20)' ) 'YDIM ', size 42 | close(21) 43 | 44 | end program wrte_ctl 45 | -------------------------------------------------------------------------------- /calc_2021Feb/add_canal/s03-divide_lonlat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/lonlat 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | WEST=${LON_ORI} 12 | while [ $WEST -lt ${LON_END} ]; 13 | do 14 | EAST=`expr $WEST + 5` 15 | 16 | SOUTH=${LAT_ORI} 17 | while [ $SOUTH -lt $LAT_END ]; 18 | do 19 | NORTH=`expr $SOUTH + 30` 20 | 21 | CNAMEIN=`./src/set_name $WEST 0` 22 | OSMFILE="./osm/devide/${CNAMEIN}-lon5.osm.pbf" 23 | 24 | CNAME=`./src/set_name $WEST $SOUTH` 25 | OUTFILE="./osm/devide/${CNAME}-lon5-lat30.osm.pbf" 26 | 27 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 28 | BBOPT="completeWays=yes completeRelations=yes" 29 | 30 | echo $OUTFILE 31 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 32 | 33 | SOUTH=`expr $SOUTH + 30` 34 | done 35 | wait 36 | WEST=`expr $WEST + 5` 37 | done 38 | wait 39 | 40 | WEST=${LON_ORI} 41 | while [ $WEST -lt ${LON_END} ]; 42 | do 43 | EAST=`expr $WEST + 5` 44 | 45 | SOUTH=${LAT_ORI} 46 | while [ $SOUTH -lt $LAT_END ]; 47 | do 48 | NORTH=`expr $SOUTH + 30` 49 | 50 | CNAMEIN=`./src/set_name $WEST $SOUTH` 51 | OSMFILE="./osm/devide/${CNAMEIN}-lon5-lat30.osm.pbf" 52 | 53 | ISOUTH=$SOUTH 54 | while [ $ISOUTH -lt $NORTH ]; 55 | do 56 | INORTH=`expr $ISOUTH + 5` 57 | 58 | CNAME=`./src/set_name $WEST $ISOUTH` 59 | OUTFILE="./osm/lonlat/${CNAME}-water.osm" 60 | 61 | BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 62 | BBOPT="completeWays=yes completeRelations=yes" 63 | 64 | echo $OUTFILE 65 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wx $OUTFILE & 66 | ISOUTH=`expr $ISOUTH + 5` 67 | done 68 | wait 69 | 70 | SOUTH=`expr $SOUTH + 30` 71 | done 72 | WEST=`expr $WEST + 5` 73 | done 74 | wait 75 | -------------------------------------------------------------------------------- /calc_2021Feb/add_river/s03-divide_lonlat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/lonlat 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | WEST=${LON_ORI} 12 | while [ $WEST -lt ${LON_END} ]; 13 | do 14 | EAST=`expr $WEST + 5` 15 | 16 | SOUTH=${LAT_ORI} 17 | while [ $SOUTH -lt $LAT_END ]; 18 | do 19 | NORTH=`expr $SOUTH + 30` 20 | 21 | CNAMEIN=`./src/set_name $WEST 0` 22 | OSMFILE="./osm/devide/${CNAMEIN}-lon5.osm.pbf" 23 | 24 | CNAME=`./src/set_name $WEST $SOUTH` 25 | OUTFILE="./osm/devide/${CNAME}-lon5-lat30.osm.pbf" 26 | 27 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 28 | BBOPT="completeWays=yes completeRelations=yes" 29 | 30 | echo $OUTFILE 31 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 32 | 33 | SOUTH=`expr $SOUTH + 30` 34 | done 35 | wait 36 | WEST=`expr $WEST + 5` 37 | done 38 | wait 39 | 40 | WEST=${LON_ORI} 41 | while [ $WEST -lt ${LON_END} ]; 42 | do 43 | EAST=`expr $WEST + 5` 44 | 45 | SOUTH=${LAT_ORI} 46 | while [ $SOUTH -lt $LAT_END ]; 47 | do 48 | NORTH=`expr $SOUTH + 30` 49 | 50 | CNAMEIN=`./src/set_name $WEST $SOUTH` 51 | OSMFILE="./osm/devide/${CNAMEIN}-lon5-lat30.osm.pbf" 52 | 53 | ISOUTH=$SOUTH 54 | while [ $ISOUTH -lt $NORTH ]; 55 | do 56 | INORTH=`expr $ISOUTH + 5` 57 | 58 | CNAME=`./src/set_name $WEST $ISOUTH` 59 | OUTFILE="./osm/lonlat/${CNAME}-water.osm" 60 | 61 | BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 62 | BBOPT="completeWays=yes completeRelations=yes" 63 | 64 | echo $OUTFILE 65 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wx $OUTFILE & 66 | ISOUTH=`expr $ISOUTH + 5` 67 | done 68 | wait 69 | 70 | SOUTH=`expr $SOUTH + 30` 71 | done 72 | WEST=`expr $WEST + 5` 73 | done 74 | wait 75 | -------------------------------------------------------------------------------- /calc_2021Feb/add_stream/s03-divide_lonlat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G" 3 | 4 | mkdir -p ./osm/lonlat 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | WEST=${LON_ORI} 12 | while [ $WEST -lt ${LON_END} ]; 13 | do 14 | EAST=`expr $WEST + 5` 15 | 16 | SOUTH=${LAT_ORI} 17 | while [ $SOUTH -lt $LAT_END ]; 18 | do 19 | NORTH=`expr $SOUTH + 30` 20 | 21 | CNAMEIN=`./src/set_name $WEST 0` 22 | OSMFILE="./osm/devide/${CNAMEIN}-lon5.osm.pbf" 23 | 24 | CNAME=`./src/set_name $WEST $SOUTH` 25 | OUTFILE="./osm/devide/${CNAME}-lon5-lat30.osm.pbf" 26 | 27 | BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 28 | BBOPT="completeWays=yes completeRelations=yes" 29 | 30 | echo $OUTFILE 31 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 32 | 33 | SOUTH=`expr $SOUTH + 30` 34 | done 35 | wait 36 | WEST=`expr $WEST + 5` 37 | done 38 | wait 39 | 40 | WEST=${LON_ORI} 41 | while [ $WEST -lt ${LON_END} ]; 42 | do 43 | EAST=`expr $WEST + 5` 44 | 45 | SOUTH=${LAT_ORI} 46 | while [ $SOUTH -lt $LAT_END ]; 47 | do 48 | NORTH=`expr $SOUTH + 30` 49 | 50 | CNAMEIN=`./src/set_name $WEST $SOUTH` 51 | OSMFILE="./osm/devide/${CNAMEIN}-lon5-lat30.osm.pbf" 52 | 53 | ISOUTH=$SOUTH 54 | while [ $ISOUTH -lt $NORTH ]; 55 | do 56 | INORTH=`expr $ISOUTH + 5` 57 | 58 | CNAME=`./src/set_name $WEST $ISOUTH` 59 | OUTFILE="./osm/lonlat/${CNAME}-water.osm" 60 | 61 | BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 62 | BBOPT="completeWays=yes completeRelations=yes" 63 | 64 | echo $OUTFILE 65 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wx $OUTFILE & 66 | ISOUTH=`expr $ISOUTH + 5` 67 | done 68 | wait 69 | 70 | SOUTH=`expr $SOUTH + 30` 71 | done 72 | WEST=`expr $WEST + 5` 73 | done 74 | wait 75 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s01-extract_water.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | mkdir -p java.tmp 5 | mkdir -p osm/water 6 | 7 | ### extract waterway & natural-water, relations and ways 8 | 9 | PLANET="./osm/planet-mod.osm.pbf" 10 | 11 | OUTFILE1="./osm/water/planet-nat_r.osm.pbf" 12 | osmosis --rbf $PLANET --tf accept-relations natural=water --uw --un --wb $OUTFILE1 & 13 | 14 | OUTFILE2="./osm/water/planet-way_r.osm.pbf" 15 | osmosis --rbf $PLANET --tf accept-relations waterway=* --uw --un --wb $OUTFILE2 & 16 | 17 | OUTFILE3="./osm/water/planet-res_r.osm.pbf" 18 | osmosis --rbf $PLANET --tf accept-relations landuse=reservoir --uw --un --wb $OUTFILE3 & 19 | 20 | 21 | OUTFILE4="./osm/water/planet-nat_w.osm.pbf" 22 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways natural=water --un --wb $OUTFILE4 & 23 | 24 | OUTFILE5="./osm/water/planet-way_w.osm.pbf" 25 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways waterway=* --un --wb $OUTFILE5 & 26 | 27 | OUTFILE6="./osm/water/planet-res_w.osm.pbf" 28 | osmosis --rbf $PLANET --tf reject-relations --tf accept-ways landuse=reservoir --un --wb $OUTFILE6 & 29 | 30 | wait 31 | 32 | ### combine all water contents 33 | 34 | OUTFILE1="./osm/water/planet-nat_w.osm.pbf" 35 | OUTFILE2="./osm/water/planet-way_w.osm.pbf" 36 | OUTFILE3="./osm/water/planet-res_w.osm.pbf" 37 | OUTFILE4="./osm/water/planet-nat_r.osm.pbf" 38 | OUTFILE5="./osm/water/planet-way_r.osm.pbf" 39 | OUTFILE6="./osm/water/planet-res_r.osm.pbf" 40 | MERGEFILE="./osm/water/planet-all.osm.pbf" 41 | TMPFILE="./osm/water/tmp_merge.osm.pbf" 42 | 43 | osmosis --rbf $OUTFILE3 --rbf $OUTFILE2 --rbf $OUTFILE1 --merge --merge --wb $TMPFILE 44 | osmosis --rbf $OUTFILE6 --rbf $OUTFILE5 --rbf $OUTFILE4 --rbf $TMPFILE --merge --merge --merge --wb $MERGEFILE 45 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/s03-divide_lonlat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export JAVACMD_OPTIONS="-Xmx4G -Djava.io.tmpdir=./java.tmp" 3 | 4 | mkdir -p ./osm/lonlat 5 | 6 | LON_ORI=-180 7 | LON_END=180 8 | LAT_ORI=-60 9 | LAT_END=90 10 | 11 | WEST=${LON_ORI} 12 | while [ $WEST -lt ${LON_END} ]; 13 | do 14 | EAST=`expr $WEST + 5` 15 | 16 | SOUTH=${LAT_ORI} 17 | while [ $SOUTH -lt $LAT_END ]; 18 | do 19 | NORTH=`expr $SOUTH + 30` 20 | 21 | CNAMEIN=`./src/set_name $WEST 0` 22 | OSMFILE="./osm/devide/${CNAMEIN}-lon5.osm.pbf" 23 | 24 | CNAME=`./src/set_name $WEST $SOUTH` 25 | OUTFILE="./osm/devide/${CNAME}-lon5-lat30.osm.pbf" 26 | 27 | # BOUND="left=${WEST} right=${EAST} top=${NORTH} bottom=${SOUTH}" 28 | BOUND=`./src/set_bounds $WEST $EAST $SOUTH $NORTH` 29 | BBOPT="completeWays=yes completeRelations=yes" 30 | 31 | echo $OUTFILE 32 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wb $OUTFILE & 33 | 34 | SOUTH=`expr $SOUTH + 30` 35 | done 36 | wait 37 | WEST=`expr $WEST + 5` 38 | done 39 | 40 | 41 | WEST=${LON_ORI} 42 | while [ $WEST -lt ${LON_END} ]; 43 | do 44 | EAST=`expr $WEST + 5` 45 | 46 | SOUTH=${LAT_ORI} 47 | while [ $SOUTH -lt $LAT_END ]; 48 | do 49 | NORTH=`expr $SOUTH + 30` 50 | 51 | CNAMEIN=`./src/set_name $WEST $SOUTH` 52 | OSMFILE="./osm/devide/${CNAMEIN}-lon5-lat30.osm.pbf" 53 | 54 | ISOUTH=$SOUTH 55 | while [ $ISOUTH -lt $NORTH ]; 56 | do 57 | INORTH=`expr $ISOUTH + 5` 58 | 59 | CNAME=`./src/set_name $WEST $ISOUTH` 60 | OUTFILE="./osm/lonlat/${CNAME}-water.osm" 61 | 62 | # BOUND="left=${WEST} right=${EAST} top=${INORTH} bottom=${ISOUTH}" 63 | BOUND=`./src/set_bounds $WEST $EAST $ISOUTH $INORTH` 64 | BBOPT="completeWays=yes completeRelations=yes" 65 | 66 | echo $OUTFILE 67 | osmosis --rbf $OSMFILE --bb $BOUND $BBOPT --wx $OUTFILE & 68 | ISOUTH=`expr $ISOUTH + 5` 69 | done 70 | wait 71 | 72 | SOUTH=`expr $SOUTH + 30` 73 | done 74 | WEST=`expr $WEST + 5` 75 | done 76 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # OSM water layer scripts 2 | The scripts to generate OSM Water Layer 3 | 4 | http://hydro.iis.u-tokyo.ac.jp/~yamadai/OSM_water/index.html 5 | 6 | Dai Yamazaki, 2nd April 2021 7 | 8 | ## Requirement 9 | Install OSMOSIS, GDAL, Fortran. 10 | The scripts are written for MacOS. Modifications might be needed for other environment. 11 | 12 | ## Procedures 13 | ### [1] Prepare "sea mask" from OSM water-polygons 14 | - Work in OSM_sea/ directory. 15 | - Detailed procedure written in ReadMe.md in OSM_sea/ 16 | 17 | ### [2] Create OSM water layer 18 | - Make a project directory (sample calc_2021Feb/ to process the OSM planet data at that time) 19 | - Go to extract_water/ directory. 20 | - Make osm/ directory, and download the latest planet.pbf from servers. 21 | - Then, follow the instruction in ReadMe.md in calc_2021Feb/ directory. 22 | 23 | ### [3] (optional) Create High-resolution OSM water layer 24 | - Make a high-res project directory (sample hires_2021Feb/ ) 25 | - Then, follow the instruction in ReadMe.md in hires_2021Feb/ directory. 26 | 27 | ### [4] Prepare distribution data 28 | - Goto distribute/ directory. 29 | - Edit copy.sh, and execute it. 30 | - Edit copy_hires.sh, and execute it. 31 | 32 | === OSM PBF file === 33 | 34 | **extract_water/osm/water/planet-all.osm.pbf** 35 | 36 | **OSM_WaterLayer.pbf** 37 | 38 | This is "derived data" and thus should be distributed under ODbL 1.0 license. 39 | 40 | === Rasterized data === 41 | 42 | 43 | 44 | Binary: **merge_water/5deg/** 45 | GeoTiff: **merge_water/tif/** 46 | 47 | 48 | 49 | Binary: **5deg/** 50 | GeoTiff: **OSM_WaterLayer_tif** 51 | 52 | These data are "creative works"(not derived data) according to the OpenStreetMap guideline. So we can put any license. Now this is distributed under CC-BY 4.0. 53 | 54 | #### Water classification in rasterlized data 55 | Below values are used in rasterlized data. 56 | 0: land 57 | 1: ocean 58 | 2: large water body (poligon) 59 | 3: majopr river 60 | 4: canal 61 | 5: small stream 62 | 63 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/draw.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | from pylab import * 5 | import numpy as np 6 | 7 | import matplotlib as mpl 8 | import matplotlib.pyplot as plt 9 | from matplotlib import colors 10 | from matplotlib.ticker import FormatStrFormatter 11 | from mpl_toolkits.axes_grid1 import make_axes_locatable 12 | 13 | import warnings;warnings.filterwarnings('ignore') 14 | 15 | class BoundaryNorm(colors.Normalize): 16 | def __init__(self, boundaries): 17 | self.vmin = boundaries[0] 18 | self.vmax = boundaries[-1] 19 | self.boundaries = boundaries 20 | self.N = len(self.boundaries) 21 | 22 | def __call__(self, x, clip=False): 23 | x = np.asarray(x) 24 | ret = np.zeros(x.shape, dtype=np.int) 25 | for i, b in enumerate(self.boundaries): 26 | ret[np.greater_equal(x, b)] = i 27 | ret[np.less(x, self.vmin)] = -1 28 | ret = np.ma.asarray(ret / float(self.N-1)) 29 | return ret 30 | 31 | argv = sys.argv 32 | west = int(argv[1]) 33 | east = int(argv[2]) 34 | south = int(argv[3]) 35 | north = int(argv[4]) 36 | cname = argv[5] 37 | outdir = argv[6] 38 | 39 | xlint=1.0 40 | ylint=1.0 41 | 42 | nx=6000 43 | ny=6000 44 | dx=1./1200. 45 | dy=1./1200. 46 | 47 | print 'dx %f' %(dx) 48 | lx=np.arange(west,east,dx) 49 | ly=np.arange(south,north,dy) 50 | 51 | print 'west %i : east %i : south %i : north %i' %(west, east, south, north) 52 | 53 | ssize=int(15) 54 | #fig=plt.figure(figsize=(40,40),dpi=100) 55 | fig=plt.figure(figsize=(ssize*1.15,ssize),dpi=100) 56 | fig.subplots_adjust(left=0.05,right=0.95,top=0.95,bottom=0.05) 57 | 58 | ax = fig.add_subplot(1,1,1) 59 | 60 | ##### 61 | rfile="./var_"+cname+".bin" 62 | a=np.fromfile(rfile,float32).reshape(6000,6000) 63 | 64 | ocean='#000066' 65 | ll="#ffffff" ## dry in both 66 | lw="#ff0000" ## wet only in OSM 67 | wl="#00ff00" ## wet only in G3WBM 68 | ww="#0000ff" ## wrt in both 69 | 70 | 71 | bounds=(array([ 0, 0.5, 1.5, 10.5, 11.5 ])).tolist() 72 | clist=[ ll, lw, wl, ww, ocean] 73 | cm=colors.ListedColormap(clist) 74 | cm.set_under(ll) 75 | 76 | im=plt.imshow(a,cmap=cm,norm=BoundaryNorm(bounds),interpolation='nearest',extent=(west,east,south,north)) 77 | ### 78 | 79 | #divider = make_axes_locatable(ax) 80 | #cax = divider.append_axes("right", size="2%", pad=0.15) 81 | 82 | savefig("./fig/"+cname+".jpg") 83 | 84 | quit() 85 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/add_lake.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: irel, nrel 6 | parameter (nrel=1000000000) 7 | 8 | integer :: itype 9 | integer,allocatable :: type(:) 10 | 11 | character*512 :: buf, buf2, first, nul 12 | 13 | character*128 :: rfile, wfile 14 | ! =============================================== 15 | allocate(type(nrel)) 16 | type(:)=0 17 | 18 | rfile='./tag_mod/water-relation-id.txt' 19 | open(11,file=rfile,form='formatted') 20 | 1000 continue 21 | read(11,*,end=1090) irel, itype 22 | type(irel)=itype 23 | goto 1000 24 | 1090 continue 25 | close(11) 26 | 27 | 28 | !==================================================== 29 | rfile='./tag_mod/notag-relation.osm' 30 | wfile='./tag_mod/water_add-relation.osm' 31 | 32 | open(11,file=rfile,form='formatted') 33 | open(21,file=wfile,form='formatted') 34 | 35 | print *, 'read header' 36 | 37 | read(11,'(a256)') buf 38 | write(21,'(a)') trim(buf) 39 | 40 | read(11,'(a256)') buf 41 | write(21,'(a)') trim(buf) 42 | 43 | read(11,'(a256)') buf 44 | write(21,'(a)') trim(buf) 45 | 46 | !==================================================== 47 | print *, 'read data' 48 | 49 | 2000 continue 50 | 51 | read(11,'(a256)',end=2090) buf 52 | read(buf,*) first 53 | if( trim(first)=='' 65 | write(21,'(a)') ' ' 66 | endif 67 | endif 68 | 69 | goto 2000 70 | 2090 continue 71 | 72 | if( itype/=2 )then 73 | write(21,*) trim(buf) 74 | endif 75 | 76 | close(11) 77 | close(21) 78 | 79 | 80 | end program check_relation 81 | 82 | 83 | 84 | !==================================================== 85 | subroutine conv_buf(buf) 86 | character*512 :: buf 87 | integer :: i 88 | 89 | do i=1, 512 90 | if( buf(i:i)=='"' ) buf(i:i)=' ' 91 | end do 92 | 93 | end subroutine conv_buf 94 | 95 | 96 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/add_lake.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: irel, nrel 6 | parameter (nrel=1000000000) 7 | 8 | integer :: itype 9 | integer,allocatable :: type(:) 10 | 11 | character*512 :: buf, buf2, first, nul 12 | 13 | character*128 :: rfile, wfile 14 | ! =============================================== 15 | allocate(type(nrel)) 16 | type(:)=0 17 | 18 | rfile='./tag_mod/water-relation-id.txt' 19 | open(11,file=rfile,form='formatted') 20 | 1000 continue 21 | read(11,*,end=1090) irel, itype 22 | type(irel)=itype 23 | goto 1000 24 | 1090 continue 25 | close(11) 26 | 27 | 28 | !==================================================== 29 | rfile='./tag_mod/notag-relation.osm' 30 | wfile='./tag_mod/water_add-relation.osm' 31 | 32 | open(11,file=rfile,form='formatted') 33 | open(21,file=wfile,form='formatted') 34 | 35 | print *, 'read header' 36 | 37 | read(11,'(a256)') buf 38 | write(21,'(a)') trim(buf) 39 | 40 | read(11,'(a256)') buf 41 | write(21,'(a)') trim(buf) 42 | 43 | read(11,'(a256)') buf 44 | write(21,'(a)') trim(buf) 45 | 46 | !==================================================== 47 | print *, 'read data' 48 | 49 | 2000 continue 50 | 51 | read(11,'(a256)',end=2090) buf 52 | read(buf,*) first 53 | if( trim(first)=='' 65 | write(21,'(a)') ' ' 66 | endif 67 | endif 68 | 69 | goto 2000 70 | 2090 continue 71 | 72 | if( itype/=2 )then 73 | write(21,*) trim(buf) 74 | endif 75 | 76 | close(11) 77 | close(21) 78 | 79 | 80 | end program check_relation 81 | 82 | 83 | 84 | !==================================================== 85 | subroutine conv_buf(buf) 86 | character*512 :: buf 87 | integer :: i 88 | 89 | do i=1, 512 90 | if( buf(i:i)=='"' ) buf(i:i)=' ' 91 | end do 92 | 93 | end subroutine conv_buf 94 | 95 | 96 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/src/merge_mask.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=6000) 8 | parameter (ny=6000) 9 | 10 | integer*1,allocatable :: water(:,:), canal(:,:), river(:,:), stream(:,:) 11 | 12 | character*7 :: cname 13 | ! =============================================== 14 | call getarg(1,cname) 15 | 16 | allocate(water(nx,ny),canal(nx,ny),river(nx,ny),stream(nx,ny)) 17 | 18 | rfile='../extract_water/5deg/'//trim(cname)//'.bil' 19 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 20 | read(11,rec=1) water 21 | close(11) 22 | 23 | rfile='../add_stream/5deg/'//trim(cname)//'.bil' 24 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 25 | read(11,rec=1) stream 26 | close(11) 27 | 28 | rfile='../add_canal/5deg/'//trim(cname)//'.bil' 29 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 30 | read(11,rec=1) canal 31 | close(11) 32 | 33 | rfile='../add_river/5deg/'//trim(cname)//'.bil' 34 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 35 | read(11,rec=1) river 36 | close(11) 37 | 38 | 39 | do iy=1, ny 40 | do ix=1, nx 41 | if( water(ix,iy)==1 )then 42 | water(ix,iy)=1 !! ocean 43 | elseif( water(ix,iy)==2 )then 44 | water(ix,iy)=3 !! line 45 | elseif( water(ix,iy)==3 )then 46 | water(ix,iy)=2 !! polygon 47 | endif 48 | end do 49 | end do 50 | 51 | do iy=1, ny 52 | do ix=1, nx 53 | if( stream(ix,iy)>=2 )then 54 | water(ix,iy)=5 !! stream 55 | endif 56 | end do 57 | end do 58 | 59 | do iy=1, ny 60 | do ix=1, nx 61 | if( canal(ix,iy)>=2 )then 62 | water(ix,iy)=4 !! canal 63 | endif 64 | end do 65 | end do 66 | 67 | do iy=1, ny 68 | do ix=1, nx 69 | if( river(ix,iy)==3 )then 70 | water(ix,iy)=2 !! line to polygon 71 | elseif( river(ix,iy)==2 )then 72 | water(ix,iy)=3 73 | endif 74 | end do 75 | end do 76 | 77 | 78 | wfile='./5deg/'//trim(cname)//'.bil' 79 | open(11,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 80 | write(11,rec=1) water 81 | close(11) 82 | 83 | end program check_area 84 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/merge_mask.f90: -------------------------------------------------------------------------------- 1 | program check_area 2 | ! =============================================== 3 | implicit none 4 | character*128 :: rfile, wfile 5 | 6 | integer :: ix, iy, nx, ny 7 | parameter (nx=10800) 8 | parameter (ny=10800) 9 | 10 | integer*1,allocatable :: water(:,:), canal(:,:), river(:,:), stream(:,:) 11 | 12 | character*7 :: cname 13 | ! =============================================== 14 | call getarg(1,cname) 15 | 16 | allocate(water(nx,ny),canal(nx,ny),river(nx,ny),stream(nx,ny)) 17 | 18 | rfile='../extract_water/1deg_10m/'//trim(cname)//'.bil' 19 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 20 | read(11,rec=1) water 21 | close(11) 22 | 23 | rfile='../add_stream/1deg_10m/'//trim(cname)//'.bil' 24 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 25 | read(11,rec=1) stream 26 | close(11) 27 | 28 | rfile='../add_canal/1deg_10m/'//trim(cname)//'.bil' 29 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 30 | read(11,rec=1) canal 31 | close(11) 32 | 33 | rfile='../add_river/1deg_10m/'//trim(cname)//'.bil' 34 | open(11,file=rfile,form='unformatted',access='direct',recl=1*nx*ny) 35 | read(11,rec=1) river 36 | close(11) 37 | 38 | 39 | do iy=1, ny 40 | do ix=1, nx 41 | if( water(ix,iy)==1 )then 42 | water(ix,iy)=1 !! ocean 43 | elseif( water(ix,iy)==2 )then 44 | water(ix,iy)=3 !! line 45 | elseif( water(ix,iy)==3 )then 46 | water(ix,iy)=2 !! polygon 47 | endif 48 | end do 49 | end do 50 | 51 | do iy=1, ny 52 | do ix=1, nx 53 | if( stream(ix,iy)>=2 )then 54 | water(ix,iy)=5 !! stream 55 | endif 56 | end do 57 | end do 58 | 59 | do iy=1, ny 60 | do ix=1, nx 61 | if( canal(ix,iy)>=2 )then 62 | water(ix,iy)=4 !! canal 63 | endif 64 | end do 65 | end do 66 | 67 | do iy=1, ny 68 | do ix=1, nx 69 | if( river(ix,iy)==3 )then 70 | water(ix,iy)=2 !! line to polygon 71 | elseif( river(ix,iy)==2 )then 72 | water(ix,iy)=3 73 | endif 74 | end do 75 | end do 76 | 77 | 78 | wfile='./1deg_10m/'//trim(cname)//'.bil' 79 | open(11,file=wfile,form='unformatted',access='direct',recl=1*nx*ny) 80 | write(11,rec=1) water 81 | close(11) 82 | 83 | end program check_area 84 | -------------------------------------------------------------------------------- /Figure/draw-change.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | from pylab import * 5 | import numpy as np 6 | 7 | import matplotlib as mpl 8 | import matplotlib.pyplot as plt 9 | from matplotlib import colors 10 | from matplotlib.ticker import FormatStrFormatter 11 | from mpl_toolkits.axes_grid1 import make_axes_locatable 12 | 13 | import warnings;warnings.filterwarnings('ignore') 14 | 15 | class BoundaryNorm(colors.Normalize): 16 | def __init__(self, boundaries): 17 | self.vmin = boundaries[0] 18 | self.vmax = boundaries[-1] 19 | self.boundaries = boundaries 20 | self.N = len(self.boundaries) 21 | 22 | def __call__(self, x, clip=False): 23 | x = np.asarray(x) 24 | ret = np.zeros(x.shape, dtype=np.int) 25 | for i, b in enumerate(self.boundaries): 26 | ret[np.greater_equal(x, b)] = i 27 | ret[np.less(x, self.vmin)] = -1 28 | ret = np.ma.asarray(ret / float(self.N-1)) 29 | return ret 30 | 31 | argv = sys.argv 32 | west = int(argv[1]) 33 | south = int(argv[2]) 34 | cname = argv[3] 35 | outdir = argv[4] 36 | 37 | east = west + 5 38 | north = south + 5 39 | 40 | xlint=1.0 41 | ylint=1.0 42 | 43 | nx=6000 44 | ny=6000 45 | dx=1./1200. 46 | dy=1./1200. 47 | 48 | lx=np.arange(west,east,dx) 49 | ly=np.arange(south,north,dy) 50 | 51 | print('west %f : east %f : south %f : north %f' %(west, east, south, north) ) 52 | 53 | ssize=int(40) 54 | #fig=plt.figure(figsize=(40,40),dpi=100) 55 | fig=plt.figure(figsize=(ssize,ssize),dpi=100) 56 | fig.subplots_adjust(left=0.05,right=0.95,top=0.95,bottom=0.05) 57 | 58 | ax = fig.add_subplot(1,1,1) 59 | 60 | ### 61 | 62 | rfile="./dif_"+cname+".bin" 63 | g1w=np.fromfile(rfile,float32).reshape(ny,nx) 64 | #g1w=np.ma.masked_where(g1w<-999,g1w) 65 | 66 | #im=plt.imshow(g1w,cmap=cm.Reds,interpolation='nearest',extent=(west,east,south,north)) 67 | 68 | ## cumtam colormap code 69 | sea='#9999cc' ## -99 70 | lnd='#ffffff' ## 0 71 | lst="#ff0000" ## 11 lost 72 | bth='#888888' # 21 both 73 | new='#0000cc' # 31 new 74 | ## 75 | bounds=(array([-5, 5, 15, 25, 35])).tolist() 76 | clist=[ lnd, lst, bth, new] 77 | cmwat=colors.ListedColormap(clist) 78 | cmwat.set_under(sea) 79 | 80 | im=plt.imshow(g1w,cmap=cmwat,norm=BoundaryNorm(bounds),interpolation='nearest',extent=(west,east,south,north)) 81 | 82 | plt.tick_params(labelsize=ssize,pad=5,length=5) 83 | plt.xticks( np.arange(west,east+0.000001,xlint) ) 84 | plt.yticks( np.arange(south,north+0.000001,ylint) ) 85 | #plt.title("Title", fontsize=ssize*2.5, loc='left',pad=20) 86 | 87 | #cb=colorbar(boundaries=bounds, fraction=0.12, aspect=45.,shrink=0.88,drawedges=True,ticks=bounds,orientation='horizontal')# ,extend='min') 88 | savefig("./"+outdir+"/"+cname+".png") 89 | 90 | quit() 91 | 92 | 93 | -------------------------------------------------------------------------------- /Figure/draw-water.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | from pylab import * 5 | import numpy as np 6 | 7 | import matplotlib as mpl 8 | import matplotlib.pyplot as plt 9 | from matplotlib import colors 10 | from matplotlib.ticker import FormatStrFormatter 11 | from mpl_toolkits.axes_grid1 import make_axes_locatable 12 | 13 | import warnings;warnings.filterwarnings('ignore') 14 | 15 | class BoundaryNorm(colors.Normalize): 16 | def __init__(self, boundaries): 17 | self.vmin = boundaries[0] 18 | self.vmax = boundaries[-1] 19 | self.boundaries = boundaries 20 | self.N = len(self.boundaries) 21 | 22 | def __call__(self, x, clip=False): 23 | x = np.asarray(x) 24 | ret = np.zeros(x.shape, dtype=np.int) 25 | for i, b in enumerate(self.boundaries): 26 | ret[np.greater_equal(x, b)] = i 27 | ret[np.less(x, self.vmin)] = -1 28 | ret = np.ma.asarray(ret / float(self.N-1)) 29 | return ret 30 | 31 | argv = sys.argv 32 | west = int(argv[1]) 33 | south = int(argv[2]) 34 | cname = argv[3] 35 | outdir = argv[4] 36 | 37 | east = west + 5 38 | north = south + 5 39 | 40 | xlint=1.0 41 | ylint=1.0 42 | 43 | nx=6000 44 | ny=6000 45 | dx=1./1200. 46 | dy=1./1200. 47 | 48 | lx=np.arange(west,east,dx) 49 | ly=np.arange(south,north,dy) 50 | 51 | print('west %f : east %f : south %f : north %f' %(west, east, south, north) ) 52 | 53 | ssize=int(40) 54 | #fig=plt.figure(figsize=(40,40),dpi=100) 55 | fig=plt.figure(figsize=(ssize,ssize),dpi=100) 56 | fig.subplots_adjust(left=0.05,right=0.95,top=0.95,bottom=0.05) 57 | 58 | ax = fig.add_subplot(1,1,1) 59 | 60 | ### 61 | 62 | rfile="./wat_"+cname+".bin" 63 | g1w=np.fromfile(rfile,float32).reshape(ny,nx) 64 | #g1w=np.ma.masked_where(g1w<-999,g1w) 65 | 66 | #im=plt.imshow(g1w,cmap=cm.Reds,interpolation='nearest',extent=(west,east,south,north)) 67 | 68 | ## cumtam colormap code 69 | sea='#9999cc' ## -99 70 | lnd='#ffffff' ## 0 71 | oth="#999999" ## 21 small 72 | can='#ff0000' # 31 canal 73 | riv='#00aa99' # 41 river line 74 | pol='#0000aa' # 51 river poly 75 | ## 76 | bounds=(array([-5, 15, 25, 35, 45, 55])).tolist() 77 | clist=[ lnd, oth, can, riv, pol] 78 | cmwat=colors.ListedColormap(clist) 79 | cmwat.set_under(sea) 80 | 81 | im=plt.imshow(g1w,cmap=cmwat,norm=BoundaryNorm(bounds),interpolation='nearest',extent=(west,east,south,north)) 82 | 83 | plt.tick_params(labelsize=ssize,pad=5,length=5) 84 | plt.xticks( np.arange(west,east+0.000001,xlint) ) 85 | plt.yticks( np.arange(south,north+0.000001,ylint) ) 86 | #plt.title("Title", fontsize=ssize*2.5, loc='left',pad=20) 87 | 88 | #cb=colorbar(boundaries=bounds, fraction=0.12, aspect=45.,shrink=0.88,drawedges=True,ticks=bounds,orientation='horizontal')# ,extend='min') 89 | savefig("./"+outdir+"/"+cname+".png") 90 | 91 | quit() 92 | 93 | 94 | -------------------------------------------------------------------------------- /calc_2021Feb/ReadMe.md: -------------------------------------------------------------------------------- 1 | # OSM water layer scripts 2 | The scripts to generate OSM Water Layer 3 | http://hydro.iis.u-tokyo.ac.jp/~yamadai/OSM_water/index.html 4 | 5 | Dai Yamazaki 6 | 7 | ## Detailed procedure to create OSM water layer 8 | Make a project directory (sample 2021Feb/ to process the OSM planet data at that time) 9 | 10 | ### [0] Download planet.pbf file 11 | Go to extract_water/ directory. 12 | Make osm/ directory, and download the latest **planet.pbf** from OSM servers 13 | 14 | ### [1] Pre-processing 15 | As planet.pbf contains errornous data, pre-processing is needed. 16 | 1. Goto extract_water/directory 17 | 2. Compile codes in src/ by Makefile 18 | 3. Execute a01-preset.sh 19 | 20 | Then, **osm/planet-mod.osm.pbf** will be outputed as pre-proccessed planet data. 21 | 22 | ### [2] Extract water 23 | Extract major water body from planet.osm 24 | 1. Goto extrat_water/ directory. 25 | 2. edit s00-link directory if needed. 26 | 3. Execute a02-waterlayer.sh script. 27 | - s01: First, water-related components are extracted from planet-mod.pbf. 28 | - s02, s03: Planet.pbf is divided into small parts corresponding to 5deg tiles. 29 | - s04: conversion from osm to shp format 30 | - s05: rasterlize at 3sec. 31 | 32 | ### [3] Add river/canal/stream 33 | Extract river-related water body from planet.osm (which might be missed in [2.2]) 34 | 1. Goto add_river/ directory. 35 | 2. edit s00-link directory if needed. 36 | 3. Compile Fortran code in src/ 37 | 4. Execute auto.sh script. 38 | - s01: First, water-related components are extracted from planet-mod.pbf. 39 | - s02, s03: Planet.pbf is divided into small parts corresponding to 5deg tiles. 40 | - s04: conversion from osm to shp format 41 | - s05: rasterlize at 3sec. 42 | 43 | 5. Follow the same proedures for canal and stream in add_canal/ and add_stream/ directory. 44 | 45 | ### [4] Merge water maps 46 | Merge the water mask extracted in [2.2] and [2.3] 47 | 1. Goto merge_water/ directory 48 | 2. Compile Fortran codes in src/ 49 | 3. execute auto.sh 50 | - s01: merge raster file (extracted water, river, canal, stream) 51 | - s02, s03: create GeoTiff file. 52 | 53 | 4. Visualize water map 54 | - goto Figure directory 55 | - compile codes in src/ 56 | - execute s04 script to make quick look figures. 57 | (MERIT DEM and G3WBM should be linked) 58 | 59 | ## Important output data 60 | ### OpenStreetMap PBF file: 61 | PBF file distributed as OSM Water Layer is **extract_water/osm/water/planet-all.osm.pbf** 62 | This is "derived data" and thus should be distributed under ODbL 1.0 license. 63 | 64 | ### Rasterized data at 3sec resolution in 5deg tile 65 | Plain binary: **merge_water/5deg/** 66 | GeoTiff: **merge_water/tif/** 67 | These data are "creative works"(not derived data) according to the OpenStreetMap guideline. So we can put any license. Now this is distributed under CC-BY 4.0. 68 | 69 | #### Water classification in rasterlized data 70 | Below values are used in rasterlized data. 71 | 0: land 72 | 1: ocean 73 | 2: large water body (poligon) 74 | 3: majopr river 75 | 4: canal 76 | 5: small stream 77 | -------------------------------------------------------------------------------- /calc_2021Feb/extract_water/src/check_relation.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: iway, nway 6 | parameter (nway=1000000000) 7 | 8 | integer*1,allocatable :: way_type(:) 9 | 10 | character*128 :: type, inout 11 | integer :: id, irelation, itype, iinner 12 | integer :: iwater 13 | 14 | integer :: count_water, count_non, nonid 15 | 16 | character*128 :: rfile, wfile 17 | 18 | ! =============================================== 19 | allocate(way_type(nway)) 20 | 21 | way_type(:)=0 22 | 23 | rfile='./tag_mod/way-id.txt' 24 | open(11,file=rfile,form='formatted') 25 | 1000 continue 26 | read(11,*,end=1090) iway 27 | way_type(iway)=1 28 | goto 1000 29 | 1090 continue 30 | close(11) 31 | 32 | rfile='./tag_mod/way-id2.txt' 33 | open(11,file=rfile,form='formatted') 34 | 1100 continue 35 | read(11,*,end=1190) iway 36 | way_type(iway)=1 37 | goto 1100 38 | 1190 continue 39 | close(11) 40 | 41 | iwater=0 42 | 43 | rfile='./tag_mod/relation-id.txt' 44 | wfile='./tag_mod/water-relation-id.txt' 45 | open(12,file=rfile,form='formatted') 46 | open(21,file=wfile,form='formatted') 47 | read(12,*) type, id, inout 48 | irelation=id 49 | itype=0 50 | iinner=0 51 | count_water=0 52 | count_non=0 53 | nonid=0 54 | 2000 continue 55 | read(12,*,end=2090) type, id, inout 56 | if( trim(type)=='relation' )then 57 | 58 | if( iinner==1 ) itype=0 59 | print *, irelation, itype !! print previous relation type 60 | if( itype>=0 ) then 61 | write(21,*) irelation, itype, count_water, count_non, nonid 62 | endif 63 | 64 | if( itype==1 ) iwater=iwater+1 65 | 66 | !! set new ID and reset value 67 | irelation=id 68 | itype=0 69 | iinner=0 70 | count_water=0 71 | count_non=0 72 | nonid=0 73 | 74 | else 75 | 76 | iway=id 77 | 78 | if( way_type(iway)==1 .and. trim(inout)=='outer' )then 79 | if( itype==0 ) itype=1 80 | if( count_non>0 ) itype=2 81 | count_water=count_water+1 82 | elseif( way_type(iway)==0 .and. trim(inout)=='outer' )then 83 | if( itype==1 ) itype=2 84 | count_non=count_non+1 85 | nonid=iway 86 | elseif( way_type(iway)==1 .and. trim(inout)=='inner' )then 87 | iinner=1 88 | endif 89 | 90 | endif 91 | goto 2000 92 | 2090 continue 93 | 94 | if( iinner==1 ) itype=0 95 | print *, irelation, itype 96 | if( itype>=0 ) then 97 | write(21,*) irelation, itype, count_water, count_non, nonid 98 | endif 99 | if( itype==1 ) iwater=iwater+1 100 | 101 | close(12) 102 | close(21) 103 | 104 | print *, 'water relation=', iwater 105 | 106 | end program check_relation 107 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/check_relation.f90: -------------------------------------------------------------------------------- 1 | program check_relation 2 | ! =============================================== 3 | implicit none 4 | ! vars 5 | integer :: iway, nway 6 | parameter (nway=1000000000) 7 | 8 | integer*1,allocatable :: way_type(:) 9 | 10 | character*128 :: type, inout 11 | integer :: id, irelation, itype, iinner 12 | integer :: iwater 13 | 14 | integer :: count_water, count_non, nonid 15 | 16 | character*128 :: rfile, wfile 17 | 18 | ! =============================================== 19 | allocate(way_type(nway)) 20 | 21 | way_type(:)=0 22 | 23 | rfile='./tag_mod/way-id.txt' 24 | open(11,file=rfile,form='formatted') 25 | 1000 continue 26 | read(11,*,end=1090) iway 27 | way_type(iway)=1 28 | goto 1000 29 | 1090 continue 30 | close(11) 31 | 32 | rfile='./tag_mod/way-id2.txt' 33 | open(11,file=rfile,form='formatted') 34 | 1100 continue 35 | read(11,*,end=1190) iway 36 | way_type(iway)=1 37 | goto 1100 38 | 1190 continue 39 | close(11) 40 | 41 | iwater=0 42 | 43 | rfile='./tag_mod/relation-id.txt' 44 | wfile='./tag_mod/water-relation-id.txt' 45 | open(12,file=rfile,form='formatted') 46 | open(21,file=wfile,form='formatted') 47 | read(12,*) type, id, inout 48 | irelation=id 49 | itype=0 50 | iinner=0 51 | count_water=0 52 | count_non=0 53 | nonid=0 54 | 2000 continue 55 | read(12,*,end=2090) type, id, inout 56 | if( trim(type)=='relation' )then 57 | 58 | if( iinner==1 ) itype=0 59 | print *, irelation, itype !! print previous relation type 60 | if( itype>=0 ) then 61 | write(21,*) irelation, itype, count_water, count_non, nonid 62 | endif 63 | 64 | if( itype==1 ) iwater=iwater+1 65 | 66 | !! set new ID and reset value 67 | irelation=id 68 | itype=0 69 | iinner=0 70 | count_water=0 71 | count_non=0 72 | nonid=0 73 | 74 | else 75 | 76 | iway=id 77 | 78 | if( way_type(iway)==1 .and. trim(inout)=='outer' )then 79 | if( itype==0 ) itype=1 80 | if( count_non>0 ) itype=2 81 | count_water=count_water+1 82 | elseif( way_type(iway)==0 .and. trim(inout)=='outer' )then 83 | if( itype==1 ) itype=2 84 | count_non=count_non+1 85 | nonid=iway 86 | elseif( way_type(iway)==1 .and. trim(inout)=='inner' )then 87 | iinner=1 88 | endif 89 | 90 | endif 91 | goto 2000 92 | 2090 continue 93 | 94 | if( iinner==1 ) itype=0 95 | print *, irelation, itype 96 | if( itype>=0 ) then 97 | write(21,*) irelation, itype, count_water, count_non, nonid 98 | endif 99 | if( itype==1 ) iwater=iwater+1 100 | 101 | close(12) 102 | close(21) 103 | 104 | print *, 'water relation=', iwater 105 | 106 | end program check_relation 107 | -------------------------------------------------------------------------------- /calc_2021Feb/merge_water/Figure/src/conv_form.f90: -------------------------------------------------------------------------------- 1 | program slope_srtm30 2 | ! =============================================== 3 | implicit none 4 | 5 | integer :: ix, iy 6 | integer :: nx, ny 7 | parameter (nx=6000) !! input 8 | parameter (ny=6000) 9 | 10 | real,allocatable :: elevtn(:,:) 11 | integer*1,allocatable :: water(:,:), osm(:,:) 12 | real,allocatable :: var(:,:) 13 | 14 | character*128 :: rfile1, wfile1 15 | integer :: ios 16 | real :: west1, south1 17 | character*7 :: cname1 18 | 19 | character*128 :: buf 20 | ! =============================================== 21 | allocate(elevtn(nx,ny),water(nx,ny),osm(nx,ny),var(nx,ny)) 22 | 23 | call getarg(1,buf) 24 | read(buf,*) west1 25 | call getarg(2,buf) 26 | read(buf,*) south1 27 | call set_name(west1,south1,cname1) 28 | 29 | rfile1='./MERIT_DEM/'//trim(cname1)//'.bin' 30 | open(11,file=rfile1,form='unformatted',access='direct',recl=4*nx*ny,status='old',iostat=ios) 31 | if( ios/=0 ) stop 32 | read(11,rec=1) elevtn 33 | close(11) 34 | 35 | rfile1='./G3WBM/'//trim(cname1)//'_wat.bil' 36 | open(11,file=rfile1,form='unformatted',access='direct',recl=1*nx*ny) 37 | read(11,rec=1) water 38 | close(11) 39 | 40 | rfile1='../5deg/'//trim(cname1)//'.bil' 41 | open(11,file=rfile1,form='unformatted',access='direct',recl=1*nx*ny) 42 | read(11,rec=1) osm 43 | close(11) 44 | 45 | ! =================================== 46 | var(:,:)=0 47 | do iy=1, ny 48 | do ix=1, nx 49 | if( elevtn(ix,iy)==-9999 )then 50 | var(ix,iy)=99 51 | else 52 | if( water(ix,iy)>=50 )then 53 | if( osm(ix,iy)==0 ) var(ix,iy)=10 54 | if( osm(ix,iy)>=1 ) var(ix,iy)=11 55 | else 56 | if( osm(ix,iy)==0 ) var(ix,iy)=0 57 | if( osm(ix,iy)>=1 ) var(ix,iy)=1 58 | endif 59 | endif 60 | end do 61 | end do 62 | 63 | 64 | 65 | wfile1='./var_'//trim(cname1)//'.bin' 66 | open(21,file=wfile1,form='unformatted',access='direct',recl=4*nx*ny) 67 | write(21,rec=1) var 68 | close(21) 69 | 70 | 71 | end program slope_srtm30 72 | 73 | 74 | 75 | 76 | 77 | subroutine set_name(lon,lat,cname) 78 | ! =============================================== 79 | implicit none 80 | ! 81 | real :: lon, lat 82 | 83 | character*1 :: ew, sn 84 | character*2 :: clat 85 | character*3 :: clon 86 | character*7 :: cname 87 | ! =============================================== 88 | if( lon<0 )then 89 | ew='w' 90 | write(clon,'(i3.3)') int(-lon) 91 | else 92 | ew='e' 93 | write(clon,'(i3.3)') int(lon) 94 | endif 95 | 96 | if( lat<0 )then 97 | sn='s' 98 | write(clat,'(i2.2)') int(-lat) 99 | else 100 | sn='n' 101 | write(clat,'(i2.2)') int(lat) 102 | endif 103 | 104 | cname=sn//clat//ew//clon 105 | 106 | end subroutine set_name 107 | 108 | -------------------------------------------------------------------------------- /hires_2021Feb/add_canal/src/upscale_1sec.f90: -------------------------------------------------------------------------------- 1 | program conv_5deg 2 | ! =============================================== 3 | implicit none 4 | ! 5 | character*128 :: buf 6 | real :: west, south 7 | ! 8 | character*7 :: cname 9 | character*128 :: finp 10 | character*128 :: fout 11 | integer :: ios 12 | ! 13 | integer :: ix, iy, dx, dy 14 | integer :: nx, ny 15 | parameter (nx=10800) 16 | parameter (ny=10800) 17 | 18 | integer :: iXX, iYY 19 | integer :: nXX, nYY 20 | parameter (nXX=3600) 21 | parameter (nYY=3600) 22 | ! input 23 | integer*1,allocatable :: inp(:,:), cst(:,:) 24 | ! input 25 | integer*1,allocatable :: out(:,:) 26 | ! ============================================================= 27 | call getarg(1,buf) 28 | read(buf,*) west 29 | call getarg(2,buf) 30 | read(buf,*) south 31 | call set_name(west,south,cname) 32 | 33 | ! ==================================== 34 | print *, 'READ FILES' 35 | 36 | allocate(inp(nx,ny)) 37 | allocate(out(nXX,nYY),cst(nXX,nYY)) 38 | 39 | ! ================================================== 40 | finp='./1deg_10m/'//trim(cname)//'.bil' 41 | open(11,file=finp,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 42 | if( ios/=0 ) stop 43 | read(11,rec=1) inp 44 | close(11) 45 | 46 | out(:,:)=0 47 | do iYY=1, nYY 48 | do iXX=1, nXX 49 | out(iXX,iYY)=0 50 | do dy=1, 3 51 | do dx=1, 3 52 | ix=dx+3*(iXX-1) 53 | iy=dy+3*(iYY-1) 54 | if( inp(ix,iy)==2 ) out(iXX,iYY)=out(iXX,iYY)+1 55 | if( inp(ix,iy)==3 ) out(iXX,iYY)=out(iXX,iYY)+11 56 | end do 57 | end do 58 | end do 59 | end do 60 | if( out(iXX,iYY)==99 ) out(iXX,iYY)=100 61 | 62 | fout='./1deg_30m/'//trim(cname)//'.bil' 63 | open(11,file=fout,form='unformatted',access='direct',recl=1*nXX*nYY) 64 | write(11,rec=1) out 65 | close(11) 66 | 67 | 68 | 69 | end program conv_5deg 70 | 71 | 72 | 73 | 74 | subroutine set_name(lon,lat,cname) 75 | ! =============================================== 76 | implicit none 77 | ! 78 | real :: lon, lat 79 | 80 | character*1 :: ew, sn 81 | character*2 :: clat 82 | character*3 :: clon 83 | character*7 :: cname 84 | ! =============================================== 85 | if( lon<0 )then 86 | ew='w' 87 | write(clon,'(i3.3)') int(-lon) 88 | else 89 | ew='e' 90 | write(clon,'(i3.3)') int(lon) 91 | endif 92 | 93 | if( lat<0 )then 94 | sn='s' 95 | write(clat,'(i2.2)') int(-lat) 96 | else 97 | sn='n' 98 | write(clat,'(i2.2)') int(lat) 99 | endif 100 | 101 | cname=sn//clat//ew//clon 102 | 103 | end subroutine set_name 104 | 105 | 106 | 107 | 108 | subroutine nextxy(ix,iy,jx,jy,dir) 109 | ! ============================================= 110 | implicit none 111 | ! 112 | integer :: ix,iy,jx,jy 113 | integer*1 :: dir 114 | ! ============================================ 115 | jx=ix 116 | jy=iy 117 | 118 | if( dir==2 .or. dir==3 .or. dir==4 )then 119 | jx=ix+1 120 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 121 | jx=ix-1 122 | endif 123 | 124 | if( dir==1 .or. dir==2 .or. dir==8 )then 125 | jy=iy-1 126 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 127 | jy=iy+1 128 | endif 129 | 130 | end subroutine nextxy 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /hires_2021Feb/add_river/src/upscale_1sec.f90: -------------------------------------------------------------------------------- 1 | program conv_5deg 2 | ! =============================================== 3 | implicit none 4 | ! 5 | character*128 :: buf 6 | real :: west, south 7 | ! 8 | character*7 :: cname 9 | character*128 :: finp 10 | character*128 :: fout 11 | integer :: ios 12 | ! 13 | integer :: ix, iy, dx, dy 14 | integer :: nx, ny 15 | parameter (nx=10800) 16 | parameter (ny=10800) 17 | 18 | integer :: iXX, iYY 19 | integer :: nXX, nYY 20 | parameter (nXX=3600) 21 | parameter (nYY=3600) 22 | ! input 23 | integer*1,allocatable :: inp(:,:), cst(:,:) 24 | ! input 25 | integer*1,allocatable :: out(:,:) 26 | ! ============================================================= 27 | call getarg(1,buf) 28 | read(buf,*) west 29 | call getarg(2,buf) 30 | read(buf,*) south 31 | call set_name(west,south,cname) 32 | 33 | ! ==================================== 34 | print *, 'READ FILES' 35 | 36 | allocate(inp(nx,ny)) 37 | allocate(out(nXX,nYY),cst(nXX,nYY)) 38 | 39 | ! ================================================== 40 | finp='./1deg_10m/'//trim(cname)//'.bil' 41 | open(11,file=finp,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 42 | if( ios/=0 ) stop 43 | read(11,rec=1) inp 44 | close(11) 45 | 46 | out(:,:)=0 47 | do iYY=1, nYY 48 | do iXX=1, nXX 49 | out(iXX,iYY)=0 50 | do dy=1, 3 51 | do dx=1, 3 52 | ix=dx+3*(iXX-1) 53 | iy=dy+3*(iYY-1) 54 | if( inp(ix,iy)==2 ) out(iXX,iYY)=out(iXX,iYY)+1 55 | if( inp(ix,iy)==3 ) out(iXX,iYY)=out(iXX,iYY)+11 56 | end do 57 | end do 58 | end do 59 | end do 60 | if( out(iXX,iYY)==99 ) out(iXX,iYY)=100 61 | 62 | fout='./1deg_30m/'//trim(cname)//'.bil' 63 | open(11,file=fout,form='unformatted',access='direct',recl=1*nXX*nYY) 64 | write(11,rec=1) out 65 | close(11) 66 | 67 | 68 | 69 | end program conv_5deg 70 | 71 | 72 | 73 | 74 | subroutine set_name(lon,lat,cname) 75 | ! =============================================== 76 | implicit none 77 | ! 78 | real :: lon, lat 79 | 80 | character*1 :: ew, sn 81 | character*2 :: clat 82 | character*3 :: clon 83 | character*7 :: cname 84 | ! =============================================== 85 | if( lon<0 )then 86 | ew='w' 87 | write(clon,'(i3.3)') int(-lon) 88 | else 89 | ew='e' 90 | write(clon,'(i3.3)') int(lon) 91 | endif 92 | 93 | if( lat<0 )then 94 | sn='s' 95 | write(clat,'(i2.2)') int(-lat) 96 | else 97 | sn='n' 98 | write(clat,'(i2.2)') int(lat) 99 | endif 100 | 101 | cname=sn//clat//ew//clon 102 | 103 | end subroutine set_name 104 | 105 | 106 | 107 | 108 | subroutine nextxy(ix,iy,jx,jy,dir) 109 | ! ============================================= 110 | implicit none 111 | ! 112 | integer :: ix,iy,jx,jy 113 | integer*1 :: dir 114 | ! ============================================ 115 | jx=ix 116 | jy=iy 117 | 118 | if( dir==2 .or. dir==3 .or. dir==4 )then 119 | jx=ix+1 120 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 121 | jx=ix-1 122 | endif 123 | 124 | if( dir==1 .or. dir==2 .or. dir==8 )then 125 | jy=iy-1 126 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 127 | jy=iy+1 128 | endif 129 | 130 | end subroutine nextxy 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /hires_2021Feb/add_stream/src/upscale_1sec.f90: -------------------------------------------------------------------------------- 1 | program conv_5deg 2 | ! =============================================== 3 | implicit none 4 | ! 5 | character*128 :: buf 6 | real :: west, south 7 | ! 8 | character*7 :: cname 9 | character*128 :: finp 10 | character*128 :: fout 11 | integer :: ios 12 | ! 13 | integer :: ix, iy, dx, dy 14 | integer :: nx, ny 15 | parameter (nx=10800) 16 | parameter (ny=10800) 17 | 18 | integer :: iXX, iYY 19 | integer :: nXX, nYY 20 | parameter (nXX=3600) 21 | parameter (nYY=3600) 22 | ! input 23 | integer*1,allocatable :: inp(:,:), cst(:,:) 24 | ! input 25 | integer*1,allocatable :: out(:,:) 26 | ! ============================================================= 27 | call getarg(1,buf) 28 | read(buf,*) west 29 | call getarg(2,buf) 30 | read(buf,*) south 31 | call set_name(west,south,cname) 32 | 33 | ! ==================================== 34 | print *, 'READ FILES' 35 | 36 | allocate(inp(nx,ny)) 37 | allocate(out(nXX,nYY),cst(nXX,nYY)) 38 | 39 | ! ================================================== 40 | finp='./1deg_10m/'//trim(cname)//'.bil' 41 | open(11,file=finp,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 42 | if( ios/=0 ) stop 43 | read(11,rec=1) inp 44 | close(11) 45 | 46 | out(:,:)=0 47 | do iYY=1, nYY 48 | do iXX=1, nXX 49 | out(iXX,iYY)=0 50 | do dy=1, 3 51 | do dx=1, 3 52 | ix=dx+3*(iXX-1) 53 | iy=dy+3*(iYY-1) 54 | if( inp(ix,iy)==2 ) out(iXX,iYY)=out(iXX,iYY)+1 55 | if( inp(ix,iy)==3 ) out(iXX,iYY)=out(iXX,iYY)+11 56 | end do 57 | end do 58 | end do 59 | end do 60 | if( out(iXX,iYY)==99 ) out(iXX,iYY)=100 61 | 62 | fout='./1deg_30m/'//trim(cname)//'.bil' 63 | open(11,file=fout,form='unformatted',access='direct',recl=1*nXX*nYY) 64 | write(11,rec=1) out 65 | close(11) 66 | 67 | 68 | 69 | end program conv_5deg 70 | 71 | 72 | 73 | 74 | subroutine set_name(lon,lat,cname) 75 | ! =============================================== 76 | implicit none 77 | ! 78 | real :: lon, lat 79 | 80 | character*1 :: ew, sn 81 | character*2 :: clat 82 | character*3 :: clon 83 | character*7 :: cname 84 | ! =============================================== 85 | if( lon<0 )then 86 | ew='w' 87 | write(clon,'(i3.3)') int(-lon) 88 | else 89 | ew='e' 90 | write(clon,'(i3.3)') int(lon) 91 | endif 92 | 93 | if( lat<0 )then 94 | sn='s' 95 | write(clat,'(i2.2)') int(-lat) 96 | else 97 | sn='n' 98 | write(clat,'(i2.2)') int(lat) 99 | endif 100 | 101 | cname=sn//clat//ew//clon 102 | 103 | end subroutine set_name 104 | 105 | 106 | 107 | 108 | subroutine nextxy(ix,iy,jx,jy,dir) 109 | ! ============================================= 110 | implicit none 111 | ! 112 | integer :: ix,iy,jx,jy 113 | integer*1 :: dir 114 | ! ============================================ 115 | jx=ix 116 | jy=iy 117 | 118 | if( dir==2 .or. dir==3 .or. dir==4 )then 119 | jx=ix+1 120 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 121 | jx=ix-1 122 | endif 123 | 124 | if( dir==1 .or. dir==2 .or. dir==8 )then 125 | jy=iy-1 126 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 127 | jy=iy+1 128 | endif 129 | 130 | end subroutine nextxy 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /hires_2021Feb/extract_water/src/upscale_1sec.f90: -------------------------------------------------------------------------------- 1 | program conv_5deg 2 | ! =============================================== 3 | implicit none 4 | ! 5 | character*128 :: buf 6 | real :: west, south 7 | ! 8 | character*7 :: cname 9 | character*128 :: finp 10 | character*128 :: fout 11 | integer :: ios 12 | ! 13 | integer :: ix, iy, dx, dy 14 | integer :: nx, ny 15 | parameter (nx=10800) 16 | parameter (ny=10800) 17 | 18 | integer :: iXX, iYY 19 | integer :: nXX, nYY 20 | parameter (nXX=3600) 21 | parameter (nYY=3600) 22 | ! input 23 | integer*1,allocatable :: inp(:,:), cst(:,:) 24 | ! input 25 | integer*1,allocatable :: out(:,:) 26 | ! ============================================================= 27 | call getarg(1,buf) 28 | read(buf,*) west 29 | call getarg(2,buf) 30 | read(buf,*) south 31 | call set_name(west,south,cname) 32 | 33 | ! ==================================== 34 | print *, 'READ FILES' 35 | 36 | allocate(inp(nx,ny)) 37 | allocate(out(nXX,nYY),cst(nXX,nYY)) 38 | 39 | ! ================================================== 40 | finp='./1deg_10m/'//trim(cname)//'.bil' 41 | open(11,file=finp,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 42 | if( ios/=0 ) stop 43 | read(11,rec=1) inp 44 | close(11) 45 | 46 | out(:,:)=0 47 | do iYY=1, nYY 48 | do iXX=1, nXX 49 | out(iXX,iYY)=0 50 | do dy=1, 3 51 | do dx=1, 3 52 | ix=dx+3*(iXX-1) 53 | iy=dy+3*(iYY-1) 54 | if( inp(ix,iy)==2 ) out(iXX,iYY)=out(iXX,iYY)+1 55 | if( inp(ix,iy)==3 ) out(iXX,iYY)=out(iXX,iYY)+11 56 | end do 57 | end do 58 | end do 59 | end do 60 | if( out(iXX,iYY)==99 ) out(iXX,iYY)=100 61 | 62 | fout='./1deg_30m/'//trim(cname)//'.bil' 63 | open(11,file=fout,form='unformatted',access='direct',recl=1*nXX*nYY) 64 | write(11,rec=1) out 65 | close(11) 66 | 67 | 68 | 69 | end program conv_5deg 70 | 71 | 72 | 73 | 74 | subroutine set_name(lon,lat,cname) 75 | ! =============================================== 76 | implicit none 77 | ! 78 | real :: lon, lat 79 | 80 | character*1 :: ew, sn 81 | character*2 :: clat 82 | character*3 :: clon 83 | character*7 :: cname 84 | ! =============================================== 85 | if( lon<0 )then 86 | ew='w' 87 | write(clon,'(i3.3)') int(-lon) 88 | else 89 | ew='e' 90 | write(clon,'(i3.3)') int(lon) 91 | endif 92 | 93 | if( lat<0 )then 94 | sn='s' 95 | write(clat,'(i2.2)') int(-lat) 96 | else 97 | sn='n' 98 | write(clat,'(i2.2)') int(lat) 99 | endif 100 | 101 | cname=sn//clat//ew//clon 102 | 103 | end subroutine set_name 104 | 105 | 106 | 107 | 108 | subroutine nextxy(ix,iy,jx,jy,dir) 109 | ! ============================================= 110 | implicit none 111 | ! 112 | integer :: ix,iy,jx,jy 113 | integer*1 :: dir 114 | ! ============================================ 115 | jx=ix 116 | jy=iy 117 | 118 | if( dir==2 .or. dir==3 .or. dir==4 )then 119 | jx=ix+1 120 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 121 | jx=ix-1 122 | endif 123 | 124 | if( dir==1 .or. dir==2 .or. dir==8 )then 125 | jy=iy-1 126 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 127 | jy=iy+1 128 | endif 129 | 130 | end subroutine nextxy 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /osmconf_water.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for OSM import 3 | # 4 | 5 | # put here the name of keys for ways that are assumed to be polygons if they are closed 6 | # see http://wiki.openstreetmap.org/wiki/Map_Features 7 | # original # closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism 8 | closed_ways_are_polygons=landuse,natural,waterway 9 | 10 | 11 | # comment to avoid laundering of keys ( ':' turned into '_' ) 12 | attribute_name_laundering=yes 13 | 14 | # uncomment to report all nodes, including the ones without any (significant) tag 15 | #report_all_nodes=yes 16 | 17 | # uncomment to report all ways, including the ones without any (significant) tag 18 | #report_all_ways=yes 19 | 20 | [points] 21 | # common attributes 22 | osm_id=yes 23 | osm_version=no 24 | osm_timestamp=no 25 | osm_uid=no 26 | osm_user=no 27 | osm_changeset=no 28 | 29 | # keys to report as OGR fields 30 | attributes=name,barrier,highway,ref,address,is_in,place,man_made 31 | # keys that, alone, are not significant enough to report a node as a OGR point 32 | unsignificant=created_by,converted_by,source,time,ele,attribution 33 | # keys that should NOT be reported in the "other_tags" field 34 | ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 35 | # uncomment to avoid creation of "other_tags" field 36 | #other_tags=no 37 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 38 | #all_tags=yes 39 | 40 | [lines] 41 | # common attributes 42 | osm_id=yes 43 | osm_version=no 44 | osm_timestamp=no 45 | osm_uid=no 46 | osm_user=no 47 | osm_changeset=no 48 | 49 | # keys to report as OGR fields 50 | # original # attributes=name,highway,waterway,aerialway,barrier,man_made 51 | attributes=waterway 52 | # keys that should NOT be reported in the "other_tags" field 53 | ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 54 | # uncomment to avoid creation of "other_tags" field 55 | #other_tags=no 56 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 57 | #all_tags=yes 58 | 59 | [multipolygons] 60 | # common attributes 61 | # note: for multipolygons, osm_id=yes instanciates a osm_id field for the id of relations 62 | # and a osm_way_id field for the id of closed ways. Both fields are exclusively set. 63 | osm_id=yes 64 | osm_version=no 65 | osm_timestamp=no 66 | osm_uid=no 67 | osm_user=no 68 | osm_changeset=no 69 | 70 | # keys to report as OGR fields 71 | # original # attributes=name,type,aeroway,amenity,admin_leve,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism 72 | attributes=landuse,natural,waterway 73 | # keys that should NOT be reported in the "other_tags" field 74 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 75 | # uncomment to avoid creation of "other_tags" field 76 | #other_tags=no 77 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 78 | #all_tags=yes 79 | 80 | [multilinestrings] 81 | # common attributes 82 | osm_id=yes 83 | osm_version=no 84 | osm_timestamp=no 85 | osm_uid=no 86 | osm_user=no 87 | osm_changeset=no 88 | 89 | # keys to report as OGR fields 90 | attributes=name,type 91 | # keys that should NOT be reported in the "other_tags" field 92 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 93 | # uncomment to avoid creation of "other_tags" field 94 | #other_tags=no 95 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 96 | #all_tags=yes 97 | 98 | [other_relations] 99 | # common attributes 100 | osm_id=yes 101 | osm_version=no 102 | osm_timestamp=no 103 | osm_uid=no 104 | osm_user=no 105 | osm_changeset=no 106 | 107 | # keys to report as OGR fields 108 | attributes=name,type 109 | # keys that should NOT be reported in the "other_tags" field 110 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 111 | # uncomment to avoid creation of "other_tags" field 112 | #other_tags=no 113 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 114 | #all_tags=yes 115 | -------------------------------------------------------------------------------- /Figure/src/conv_water.f90: -------------------------------------------------------------------------------- 1 | program slope_srtm30 2 | ! =============================================== 3 | implicit none 4 | 5 | integer :: ix, iy, jx, jy, kx, ky, dx, dy, sx, sy 6 | integer :: mx, my 7 | parameter (mx=6000) !! calc domain 8 | parameter (my=6000) 9 | 10 | integer*1,allocatable :: osm(:,:) 11 | real,allocatable :: var(:,:), ori(:,:) 12 | 13 | integer :: pek_thrs, pg, ng 14 | real :: dd, var_this 15 | 16 | real :: upa_thrs 17 | parameter (upa_thrs=1) 18 | 19 | character*128 :: rfile1, wfile1 20 | integer :: ios 21 | real :: west1, south1 22 | character*7 :: cname1 23 | 24 | character*128 :: buf 25 | ! =============================================== 26 | allocate(osm(mx,my)) 27 | allocate(var(mx,my),ori(mx,my)) 28 | 29 | call getarg(1,buf) 30 | read(buf,*) west1 31 | call getarg(2,buf) 32 | read(buf,*) south1 33 | call set_name(west1,south1,cname1) 34 | 35 | rfile1='./2021Feb/'//trim(cname1)//'.bil' 36 | open(11,file=rfile1,form='unformatted',access='direct',recl=1*mx*my,status='old',iostat=ios) 37 | if( ios/=0 ) stop 38 | read(11,rec=1) osm 39 | close(11) 40 | 41 | ! =================================== 42 | var(:,:)=0 43 | do iy=1, my 44 | do ix=1, mx 45 | if( osm(ix,iy)==1 ) var(ix,iy)=-99 !! ocean 46 | if( osm(ix,iy)==2 ) var(ix,iy)=51 !! ocean 47 | if( osm(ix,iy)==3 ) var(ix,iy)=41 !! ocean 48 | if( osm(ix,iy)==4 ) var(ix,iy)=31 !! ocean 49 | if( osm(ix,iy)==5 ) var(ix,iy)=21 !! ocean 50 | end do 51 | end do 52 | 53 | ori(:,:)=var(:,:) 54 | do iy=1, my 55 | do ix=1, mx 56 | if( ori(ix,iy)>0 )then 57 | var_this=ori(ix,iy) 58 | do dx=-1, 1 59 | do dy=-1, 1 60 | jx=ix+dx 61 | jy=iy+dy 62 | if( jx>=1 .and. jx<=mx .and. jy>=1 .and. jy<=my )then 63 | if( var(jx,jy)>=0 )then 64 | var(jx,jy)=max(var(jx,jy),var_this) 65 | endif 66 | endif 67 | end do 68 | end do 69 | endif 70 | end do 71 | end do 72 | 73 | wfile1='./wat_'//trim(cname1)//'.bin' 74 | open(21,file=wfile1,form='unformatted',access='direct',recl=4*mx*my) 75 | write(21,rec=1) var 76 | close(21) 77 | 78 | end program slope_srtm30 79 | 80 | 81 | 82 | 83 | 84 | subroutine set_name(lon,lat,cname) 85 | ! =============================================== 86 | implicit none 87 | ! 88 | real :: lon, lat 89 | 90 | character*1 :: ew, sn 91 | character*2 :: clat 92 | character*3 :: clon 93 | character*7 :: cname 94 | ! =============================================== 95 | if( lon<0 )then 96 | ew='w' 97 | write(clon,'(i3.3)') int(-lon) 98 | else 99 | ew='e' 100 | write(clon,'(i3.3)') int(lon) 101 | endif 102 | 103 | if( lat<0 )then 104 | sn='s' 105 | write(clat,'(i2.2)') int(-lat) 106 | else 107 | sn='n' 108 | write(clat,'(i2.2)') int(lat) 109 | endif 110 | 111 | cname=sn//clat//ew//clon 112 | 113 | end subroutine set_name 114 | 115 | 116 | 117 | 118 | 119 | subroutine nextxy(ix,iy,jx,jy,dir) 120 | ! ============================================= 121 | implicit none 122 | ! 123 | integer :: ix,iy,jx,jy 124 | integer*1 :: dir 125 | ! ============================================ 126 | jx=ix 127 | jy=iy 128 | 129 | if( dir==2 .or. dir==3 .or. dir==4 )then 130 | jx=ix+1 131 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 132 | jx=ix-1 133 | endif 134 | 135 | if( dir==1 .or. dir==2 .or. dir==8 )then 136 | jy=iy-1 137 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 138 | jy=iy+1 139 | endif 140 | 141 | end subroutine nextxy 142 | 143 | -------------------------------------------------------------------------------- /Figure/src/conv_change.f90: -------------------------------------------------------------------------------- 1 | program slope_srtm30 2 | ! =============================================== 3 | implicit none 4 | 5 | integer :: ix, iy, jx, jy, kx, ky, dx, dy, sx, sy 6 | integer :: mx, my 7 | parameter (mx=6000) !! calc domain 8 | parameter (my=6000) 9 | 10 | integer*1,allocatable :: osm(:,:), old(:,:) 11 | real,allocatable :: var(:,:), ori(:,:) 12 | 13 | integer :: pek_thrs, pg, ng 14 | real :: dd, var_this 15 | 16 | real :: upa_thrs 17 | parameter (upa_thrs=1) 18 | 19 | character*128 :: rfile1, wfile1 20 | integer :: ios 21 | real :: west1, south1 22 | character*7 :: cname1 23 | 24 | character*128 :: buf 25 | ! =============================================== 26 | allocate(osm(mx,my),old(mx,my)) 27 | allocate(var(mx,my),ori(mx,my)) 28 | 29 | call getarg(1,buf) 30 | read(buf,*) west1 31 | call getarg(2,buf) 32 | read(buf,*) south1 33 | call set_name(west1,south1,cname1) 34 | 35 | rfile1='./2021Feb/'//trim(cname1)//'.bil' 36 | open(11,file=rfile1,form='unformatted',access='direct',recl=1*mx*my,status='old',iostat=ios) 37 | if( ios/=0 ) stop 38 | read(11,rec=1) osm 39 | close(11) 40 | 41 | rfile1='./2015Aug/'//trim(cname1)//'.bil' 42 | open(11,file=rfile1,form='unformatted',access='direct',recl=1*mx*my,status='old',iostat=ios) 43 | if( ios==0 ) then 44 | read(11,rec=1) old 45 | close(11) 46 | else 47 | old(:,:)=0 48 | endif 49 | 50 | ! =================================== 51 | var(:,:)=0 52 | do iy=1, my 53 | do ix=1, mx 54 | if( osm(ix,iy)==1 )then 55 | var(ix,iy)=-99 !! ocean 56 | else 57 | if( osm(ix,iy)>=2 .and. old(ix,iy)<2 ) var(ix,iy)=31 !! new 58 | if( osm(ix,iy)>=2 .and. old(ix,iy)>=2 ) var(ix,iy)=21 !! both 59 | if( osm(ix,iy)<2 .and. old(ix,iy)>=2 ) var(ix,iy)=11 !! lost 60 | endif 61 | end do 62 | end do 63 | 64 | ori(:,:)=var(:,:) 65 | do iy=1, my 66 | do ix=1, mx 67 | if( ori(ix,iy)>0 )then 68 | var_this=ori(ix,iy) 69 | do dx=-1, 1 70 | do dy=-1, 1 71 | jx=ix+dx 72 | jy=iy+dy 73 | if( jx>=1 .and. jx<=mx .and. jy>=1 .and. jy<=my )then 74 | if( var(jx,jy)>=0 )then 75 | var(jx,jy)=max(var(jx,jy),var_this) 76 | endif 77 | endif 78 | end do 79 | end do 80 | endif 81 | end do 82 | end do 83 | 84 | wfile1='./dif_'//trim(cname1)//'.bin' 85 | open(21,file=wfile1,form='unformatted',access='direct',recl=4*mx*my) 86 | write(21,rec=1) var 87 | close(21) 88 | 89 | end program slope_srtm30 90 | 91 | 92 | 93 | 94 | 95 | subroutine set_name(lon,lat,cname) 96 | ! =============================================== 97 | implicit none 98 | ! 99 | real :: lon, lat 100 | 101 | character*1 :: ew, sn 102 | character*2 :: clat 103 | character*3 :: clon 104 | character*7 :: cname 105 | ! =============================================== 106 | if( lon<0 )then 107 | ew='w' 108 | write(clon,'(i3.3)') int(-lon) 109 | else 110 | ew='e' 111 | write(clon,'(i3.3)') int(lon) 112 | endif 113 | 114 | if( lat<0 )then 115 | sn='s' 116 | write(clat,'(i2.2)') int(-lat) 117 | else 118 | sn='n' 119 | write(clat,'(i2.2)') int(lat) 120 | endif 121 | 122 | cname=sn//clat//ew//clon 123 | 124 | end subroutine set_name 125 | 126 | 127 | 128 | 129 | 130 | subroutine nextxy(ix,iy,jx,jy,dir) 131 | ! ============================================= 132 | implicit none 133 | ! 134 | integer :: ix,iy,jx,jy 135 | integer*1 :: dir 136 | ! ============================================ 137 | jx=ix 138 | jy=iy 139 | 140 | if( dir==2 .or. dir==3 .or. dir==4 )then 141 | jx=ix+1 142 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 143 | jx=ix-1 144 | endif 145 | 146 | if( dir==1 .or. dir==2 .or. dir==8 )then 147 | jy=iy-1 148 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 149 | jy=iy+1 150 | endif 151 | 152 | end subroutine nextxy 153 | 154 | -------------------------------------------------------------------------------- /hires_2021Feb/merge_water/src/upscale_1sec.f90: -------------------------------------------------------------------------------- 1 | program conv_5deg 2 | ! =============================================== 3 | implicit none 4 | ! 5 | character*128 :: buf 6 | real :: west, south 7 | ! 8 | character*7 :: cname 9 | character*128 :: finp 10 | character*128 :: fout 11 | integer :: ios 12 | ! 13 | integer :: ix, iy, dx, dy 14 | integer :: nx, ny 15 | parameter (nx=10800) 16 | parameter (ny=10800) 17 | 18 | integer :: iXX, iYY 19 | integer :: nXX, nYY 20 | parameter (nXX=3600) 21 | parameter (nYY=3600) 22 | ! input 23 | integer*1,allocatable :: inp(:,:), cst(:,:) 24 | ! input 25 | integer*1,allocatable :: out(:,:) 26 | 27 | integer :: isPoly 28 | ! ============================================================= 29 | call getarg(1,buf) 30 | read(buf,*) west 31 | call getarg(2,buf) 32 | read(buf,*) south 33 | call set_name(west,south,cname) 34 | 35 | ! ==================================== 36 | print *, 'READ FILES' 37 | 38 | allocate(inp(nx,ny)) 39 | allocate(out(nXX,nYY),cst(nXX,nYY)) 40 | 41 | ! ================================================== 42 | finp='./1deg_10m/'//trim(cname)//'.bil' 43 | open(11,file=finp,form='unformatted',access='direct',recl=1*nx*ny,status='old',iostat=ios) 44 | if( ios/=0 ) stop 45 | read(11,rec=1) inp 46 | close(11) 47 | 48 | !! input : 2=polygon, 3=river, 4=canal, 5=stream 49 | !! output : >10:polygon, 5=river, 2=canal, 1=stream 50 | 51 | out(:,:)=0 52 | do iYY=1, nYY 53 | do iXX=1, nXX 54 | out(iXX,iYY)=0 55 | isPoly=0 56 | do dy=1, 3 57 | do dx=1, 3 58 | ix=dx+3*(iXX-1) 59 | iy=dy+3*(iYY-1) 60 | if( inp(ix,iy)==2 ) isPoly=1 61 | end do 62 | end do 63 | 64 | if( isPoly==1 )then 65 | do dy=1, 3 66 | do dx=1, 3 67 | ix=dx+3*(iXX-1) 68 | iy=dy+3*(iYY-1) 69 | if( inp(ix,iy)>0 ) out(iXX,iYY)=out(iXX,iYY)+11 70 | end do 71 | end do 72 | else 73 | do dy=1, 3 74 | do dx=1, 3 75 | ix=dx+3*(iXX-1) 76 | iy=dy+3*(iYY-1) 77 | if( inp(ix,iy)==3 .and. out(iXX,iYY)<5 ) out(iXX,iYY)=5 78 | if( inp(ix,iy)==4 .and. out(iXX,iYY)<2 ) out(iXX,iYY)=2 79 | if( inp(ix,iy)==5 .and. out(iXX,iYY)<1 ) out(iXX,iYY)=1 80 | end do 81 | end do 82 | endif 83 | 84 | if( out(iXX,iYY)==99 ) out(iXX,iYY)=100 85 | 86 | end do 87 | end do 88 | 89 | fout='./1deg_30m/'//trim(cname)//'.bil' 90 | print *, fout 91 | open(11,file=fout,form='unformatted',access='direct',recl=1*nXX*nYY) 92 | write(11,rec=1) out 93 | close(11) 94 | 95 | 96 | 97 | end program conv_5deg 98 | 99 | 100 | 101 | 102 | subroutine set_name(lon,lat,cname) 103 | ! =============================================== 104 | implicit none 105 | ! 106 | real :: lon, lat 107 | 108 | character*1 :: ew, sn 109 | character*2 :: clat 110 | character*3 :: clon 111 | character*7 :: cname 112 | ! =============================================== 113 | if( lon<0 )then 114 | ew='w' 115 | write(clon,'(i3.3)') int(-lon) 116 | else 117 | ew='e' 118 | write(clon,'(i3.3)') int(lon) 119 | endif 120 | 121 | if( lat<0 )then 122 | sn='s' 123 | write(clat,'(i2.2)') int(-lat) 124 | else 125 | sn='n' 126 | write(clat,'(i2.2)') int(lat) 127 | endif 128 | 129 | cname=sn//clat//ew//clon 130 | 131 | end subroutine set_name 132 | 133 | 134 | 135 | 136 | subroutine nextxy(ix,iy,jx,jy,dir) 137 | ! ============================================= 138 | implicit none 139 | ! 140 | integer :: ix,iy,jx,jy 141 | integer*1 :: dir 142 | ! ============================================ 143 | jx=ix 144 | jy=iy 145 | 146 | if( dir==2 .or. dir==3 .or. dir==4 )then 147 | jx=ix+1 148 | elseif( dir==6 .or. dir==7 .or. dir==8 )then 149 | jx=ix-1 150 | endif 151 | 152 | if( dir==1 .or. dir==2 .or. dir==8 )then 153 | jy=iy-1 154 | elseif( dir==4 .or. dir==5 .or. dir==6 )then 155 | jy=iy+1 156 | endif 157 | 158 | end subroutine nextxy 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /osmconf.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for OSM import 3 | # 4 | 5 | # put here the name of keys for ways that are assumed to be polygons if they are closed 6 | # see http://wiki.openstreetmap.org/wiki/Map_Features 7 | closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism 8 | 9 | # comment to avoid laundering of keys ( ':' turned into '_' ) 10 | attribute_name_laundering=yes 11 | 12 | # uncomment to report all nodes, including the ones without any (significant) tag 13 | #report_all_nodes=yes 14 | 15 | # uncomment to report all ways, including the ones without any (significant) tag 16 | #report_all_ways=yes 17 | 18 | [points] 19 | # common attributes 20 | osm_id=yes 21 | osm_version=no 22 | osm_timestamp=no 23 | osm_uid=no 24 | osm_user=no 25 | osm_changeset=no 26 | 27 | # keys to report as OGR fields 28 | attributes=name,barrier,highway,ref,address,is_in,place,man_made 29 | # keys that, alone, are not significant enough to report a node as a OGR point 30 | unsignificant=created_by,converted_by,source,time,ele,attribution 31 | # keys that should NOT be reported in the "other_tags" field 32 | ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 33 | # uncomment to avoid creation of "other_tags" field 34 | #other_tags=no 35 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 36 | #all_tags=yes 37 | 38 | [lines] 39 | # common attributes 40 | osm_id=yes 41 | osm_version=no 42 | osm_timestamp=no 43 | osm_uid=no 44 | osm_user=no 45 | osm_changeset=no 46 | 47 | # keys to report as OGR fields 48 | attributes=name,highway,waterway,aerialway,barrier,man_made 49 | 50 | # type of attribute 'foo' can be changed with something like 51 | #foo_type=Integer/Real/String/DateTime 52 | 53 | # keys that should NOT be reported in the "other_tags" field 54 | ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 55 | # uncomment to avoid creation of "other_tags" field 56 | #other_tags=no 57 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 58 | #all_tags=yes 59 | 60 | #computed_attributes must appear before the keywords _type and _sql 61 | computed_attributes=z_order 62 | z_order_type=Integer 63 | # Formula based on https://github.com/openstreetmap/osm2pgsql/blob/master/style.lua#L13 64 | # [foo] is substituted by value of tag foo. When substitution is not wished, the [ character can be escaped with \[ in literals 65 | z_order_sql="SELECT (CASE [highway] WHEN 'minor' THEN 3 WHEN 'road' THEN 3 WHEN 'unclassified' THEN 3 WHEN 'residential' THEN 3 WHEN 'tertiary_link' THEN 4 WHEN 'tertiary' THEN 4 WHEN 'secondary_link' THEN 6 WHEN 'secondary' THEN 6 WHEN 'primary_link' THEN 7 WHEN 'primary' THEN 7 WHEN 'trunk_link' THEN 8 WHEN 'trunk' THEN 8 WHEN 'motorway_link' THEN 9 WHEN 'motorway' THEN 9 ELSE 0 END) + (CASE WHEN [bridge] IN ('yes', 'true', '1') THEN 10 ELSE 0 END) + (CASE WHEN [tunnel] IN ('yes', 'true', '1') THEN -10 ELSE 0 END) + (CASE WHEN [railway] IS NOT NULL THEN 5 ELSE 0 END) + (CASE WHEN [layer] IS NOT NULL THEN 10 * CAST([layer] AS INTEGER) ELSE 0 END)" 66 | 67 | [multipolygons] 68 | # common attributes 69 | # note: for multipolygons, osm_id=yes instanciates a osm_id field for the id of relations 70 | # and a osm_way_id field for the id of closed ways. Both fields are exclusively set. 71 | osm_id=yes 72 | osm_version=no 73 | osm_timestamp=no 74 | osm_uid=no 75 | osm_user=no 76 | osm_changeset=no 77 | 78 | # keys to report as OGR fields 79 | attributes=name,type,aeroway,amenity,admin_level,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism 80 | # keys that should NOT be reported in the "other_tags" field 81 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 82 | # uncomment to avoid creation of "other_tags" field 83 | #other_tags=no 84 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 85 | #all_tags=yes 86 | 87 | [multilinestrings] 88 | # common attributes 89 | osm_id=yes 90 | osm_version=no 91 | osm_timestamp=no 92 | osm_uid=no 93 | osm_user=no 94 | osm_changeset=no 95 | 96 | # keys to report as OGR fields 97 | attributes=name,type 98 | # keys that should NOT be reported in the "other_tags" field 99 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 100 | # uncomment to avoid creation of "other_tags" field 101 | #other_tags=no 102 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 103 | #all_tags=yes 104 | 105 | [other_relations] 106 | # common attributes 107 | osm_id=yes 108 | osm_version=no 109 | osm_timestamp=no 110 | osm_uid=no 111 | osm_user=no 112 | osm_changeset=no 113 | 114 | # keys to report as OGR fields 115 | attributes=name,type 116 | # keys that should NOT be reported in the "other_tags" field 117 | ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME 118 | # uncomment to avoid creation of "other_tags" field 119 | #other_tags=no 120 | # uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive 121 | #all_tags=yes 122 | --------------------------------------------------------------------------------