Last active
September 13, 2022 19:40
-
-
Save neogeogre/6e353293f3057cc193cc814777174ef6 to your computer and use it in GitHub Desktop.
run gdal and qgis only with docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdal_edit.py \ | |
-gcp 10590 5452 -47.6504744 -20.7733625 \ # assign a gcp order is : pix_x pix_y lon lat | |
-gcp 8120 2911 -47.6513638 -20.7725031 \ | |
-gcp 13985 5237 -47.6492496 -20.7732887 \ | |
-gcp 13352 9067 -47.6494754 -20.7745861 \ | |
-gcp 6626 7356 -47.6518992 -20.7740086 \ | |
orthomosaic.tif # Set GCP pixels and according geographic coordinates | |
gdalwarp -tps -r bilinear orthomosaic.tif orthomosaic2.tif # do the transfo using the preassigned GCPs | |
gdal_edit.py -a_srs EPSG:4326 orthomosaic2.tif # reassigne the EPSG code which was lost during transfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -it --rm \ | |
--user $(id -u):$(id -g) \ | |
-v ~/Desktop:/tmp \ | |
osgeo/gdal:latest /bin/bash -c \ | |
"ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:3857 /tmp/output.geojson /tmp/input.geojson" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdalbuildvrt mosaic.vrt 0.tif 1.tif 2.tif 3.tif | |
gdalwarp mosaic.vrt mosaic.tif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xhost +local:root && \ | |
docker run --rm -it --name qgis \ | |
-e DISPLAY=unix$DISPLAY \ | |
-v /tmp/.X11-unix:/tmp/.X11-unix \ | |
-v /home:/home \ | |
qgis/qgis:latest qgis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
stackMultispectral() { | |
VIRT_DIR="/virtualDirectory" | |
blue="${VIRT_DIR}/project_transparent_mosaic_blue.tif" | |
green="${VIRT_DIR}/project_transparent_mosaic_green.tif" | |
red="${VIRT_DIR}/project_transparent_mosaic_red.tif" | |
rededge="${VIRT_DIR}/project_transparent_mosaic_red\ edge.tif" | |
nir="${VIRT_DIR}/project_transparent_mosaic_nir.tif" | |
blue1="${VIRT_DIR}/project_transparent_mosaic_blue1.tif" | |
green1="${VIRT_DIR}/project_transparent_mosaic_green1.tif" | |
red1="${VIRT_DIR}/project_transparent_mosaic_red1.tif" | |
rededge1="${VIRT_DIR}/project_transparent_mosaic_red\ edge1.tif" | |
nir1="${VIRT_DIR}/project_transparent_mosaic_nir1.tif" | |
stacked="${VIRT_DIR}/stacked.tif" | |
CMD1="gdal_translate -of GTiff ${blue} ${blue1} -b 1 && chmod -R o+rwx ${blue1}" | |
CMD2="gdal_translate -of GTiff ${green} ${green1} -b 1 && chmod -R o+rwx ${green1}" | |
CMD3="gdal_translate -of GTiff ${red} ${red1} -b 1 && chmod -R o+rwx ${red1}" | |
CMD4="gdal_translate -of GTiff ${rededge} ${rededge1} -b 1 && chmod -R o+rwx ${rededge1}" | |
CMD5="gdal_translate -of GTiff ${nir} ${nir1} -b 1 && chmod -R o+rwx ${nir1}" | |
CMD6="gdal_merge.py -o ${stacked} -separate ${blue1} ${green1} ${red1} ${rededge1} ${nir1} && chmod -R o+rwx ${stacked}" | |
docker run -v $1:${VIRT_DIR} --rm osgeo/gdal:ubuntu-full-latest \ | |
/bin/bash -c "export GDAL_CACHEMAX=70%;${CMD1};${CMD2};${CMD3};${CMD4};${CMD5};${CMD6}" | |
} | |
stackMultispectral "/home/gamaya/Desktop/multispectral/out100/project/3_dsm_ortho/2_mosaic" | |
stackMultispectral "/home/gamaya/Desktop/multispectral/out103/project/3_dsm_ortho/2_mosaic" | |
stackMultispectral "/home/gamaya/Desktop/multispectral/out104/project/3_dsm_ortho/2_mosaic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
gdal_edit.py 0 0 -47.57044 -20.98482 5 5 -47.56943 -20.98486 0 5 -47.57051 -20.98593 sample.tif | |
gdalwarp -tps -r bilinear sample.tif sample2.tif | |
gdal_translate -of GTiff -a_srs EPSG:4326 \ | |
-gcp 0 0 -47.57044 -20.98482 \ | |
-gcp 0 5 -47.56943 -20.98486 \ | |
-gcp 0 5 -47.57051 -20.98593 \ | |
-gcp 5 5 -47.56960 -20.98602 \ | |
sample.tif out1.tif | |
gdalwarp -r near -order 2 -co COMPRESS=NONE out1.tif out2.tif | |
gdal_edit.py \ | |
-gcp 0 0 -47.57010 -20.98533 \ | |
-gcp 0 5 -47.56930 -20.98535 \ | |
-gcp 5 5 -47.56931 -20.98590 \ | |
sample.tif | |
gdalwarp -tps -r bilinear sample.tif sample2.tif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment