我获得了这个BASH脚本,它列出并告诉我目录中没有数据值的不同类型。
basepath=/home/rose/Desktop/GreatExtentDSMnodatacleaned #change this as top level directory
nodata_NEW='-9999'
cd $basepath
dir_list=$(ls -d -1 $PWD/**) #create list of directories
for i in $dir_list
do
cd $i
for f in *.tif; do
gdalinfo "$f" | grep -o 'NoData Value\=[-0-9]*' || echo "NoData Value=None";
done | uniq
done
done
我想知道目录中的所有文件是否具有相同的投影,如果没有,则列出它们。这是我正在使用的.tif文件之一的gdalinfo,具有正确的投影类型,基准面和椭球体;
rose@Thinkpad:~/Desktop/GreatExtentDSM/1100LeeDam$ gdalinfo BQ26_2011_2000_2301.tif
Driver: GTiff/GeoTIFF
Files: BQ26_2011_2000_2301.tif
Size is 960, 1440
Coordinate System is:
PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",
GEOGCS["NZGD2000",
DATUM["New_Zealand_Geodetic_Datum_2000",
SPHEROID["GRS 1980",6378137,298.2572221008872,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6167"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4167"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",173],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",1600000],
PARAMETER["false_northing",10000000],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","2193"]]
Origin = (1612000.000000000000000,5410320.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( 1612000.000, 5410320.000) (173d 8'37.27"E, 41d27'31.02"S)
Lower Left ( 1612000.000, 5408880.000) (173d 8'37.37"E, 41d28'17.72"S)
Upper Right ( 1612960.000, 5410320.000) (173d 9'18.65"E, 41d27'30.97"S)
Lower Right ( 1612960.000, 5408880.000) (173d 9'18.76"E, 41d28'17.67"S)
Center ( 1612480.000, 5409600.000) (173d 8'58.01"E, 41d27'54.35"S)
Band 1 Block=960x1 Type=Float32, ColorInterp=Gray
NoData Value=-100
如何修改上述脚本以检查不同的投影等?
答案 0 :(得分:0)
Found the answer;
basepath=/home/rose/Desktop/test/0900Rich/*.tif
echo $basepath
list=$(ls $basepath)
for i in $list
do
gdalsrsinfo $i | grep 'PROJ.4 : '* || echo 'PROJ.4 : '
#create text file with echo contents in it somewhere in here?
done
This BASH script gives a list of echo outputs;
PROJ.4 : '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '
PROJ.4 : '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '
PROJ.4 : '+proj=tmerc +lat_0=0 +lon_0=173 +k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '
How do I create a text file with the output projections inside it? Tried defining the command in the for loop as a variable and >> to a text file but that did not work.