-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Se añaden algunas mejoas en procesamiento por paquetes de imagenes
- Loading branch information
Showing
10 changed files
with
208 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
tic | ||
%comprimir a solo valores <0 en indice NDVI | ||
[I,J]=find(v_iv<0);%usar J que entrega todos los índices en que ocurre | ||
r=1; | ||
for i=1:length(v_iv) | ||
if isempty(find(J==i)) | ||
short_v_iv(r)=v_iv(i); | ||
short_v_lon(r)=b_lon(i); | ||
short_v_lat(r)=b_lat(i); | ||
r=1+r; | ||
end | ||
end | ||
test2 = struct('Geometry', 'Multipoint', 'id', num2cell(v_iv), 'X', num2cell(b_lon), 'Y', num2cell(b_lat)); | ||
%shapewrite(test2, 'test2'); | ||
toc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
list_dir=dir(fullfile(path,type)); | ||
list_dir={list_dir.name}; | ||
out=list_dir; | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
Ruta='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/img_ANG006_IMG/IMG/' | ||
cd(Ruta); | ||
pwd | ||
Carpeta_output='Output'; | ||
%INDICES={'NDVI','NDWI'}; | ||
%programa que lee línea a línea el LOG MTL | ||
BaseDir='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat'; | ||
LogTXT='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/Logs/archivos_MTL_ANG006_IMG.txt'; | ||
FID=fopen(LogTXT,'r'); | ||
UTM_x=[372560,387500]; | ||
%si entregan datos en UTM sur se deben convertir a norte ya que landsat | ||
%entrega en UTM norte | ||
UTM_y=[6328630,6307300]-10000000; | ||
I=1; | ||
tic | ||
Rc=[]; | ||
while ~feof(FID) | ||
leer_linea=fgetl(FID); | ||
File='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/img_ANG006_IMG/IMG'; | ||
TOTDIR='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/img_ANG006_IMG/TOT/'; | ||
Ruta='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/img_ANG006_IMG/IMG'; | ||
Nombre_Proceso='ANG006_IMG'; | ||
dese=desmembrar(leer_linea,'/'); | ||
[dn,dm]=size(dese); | ||
name_des=char(cellstr(dese(dn-1:1))) | ||
set_DIR=['/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/img_ANG006_IMG/IMG/',name_des] | ||
cd(set_DIR) | ||
set_DIR | ||
pwd | ||
%'listar tif en carpeta | ||
[A,L]=unix('find -name "*.TIF"'); | ||
des=desmembrar(L,'./'); | ||
[nd,md]=size(des); | ||
%usar L{i}(2:end) para extraer nombre de archivo | ||
%nd=1 | ||
I=zeros(711,498,nd); | ||
for i=1:nd | ||
|
||
%'leer cada imagen tif | ||
%'cortar cada imagen tif | ||
name=char(cellstr(des{i}(2:end))); | ||
FileName=[set_DIR '/' name]; | ||
if ~strcmp(UTM_x,'') || ~strcmp(CorteY,'') | ||
%filtrar y omitir banda 6 que es mas densa | ||
Rx=Rc | ||
[IMc,Rc, X, R, INFOx]=corte_imagen(BaseDir,FileName,UTM_x,UTM_y); | ||
[n,m]=size(IMc); | ||
end | ||
bla=char(desmembrar(name,'_')); | ||
banda=bla(1:end-4); | ||
switch banda | ||
case 'B1' | ||
capa=1; | ||
case 'B2' | ||
capa=2; | ||
case 'B3' | ||
capa=3; | ||
case 'B4' | ||
capa=4; | ||
case 'B5' | ||
capa=5; | ||
case 'B6' | ||
capa=6; | ||
case 'B7' | ||
capa=7; | ||
case 'B8' | ||
capa=8; | ||
case 'B9' | ||
capa=9; | ||
case 'B10' | ||
capa=10; | ||
case 'B11' | ||
capa=11; | ||
case 'BQA' | ||
capa=12; | ||
end | ||
|
||
|
||
[n,m]=size(IMc) | ||
ele_banda=banda | ||
comparacion=~strcmp(char(banda),'B8') | ||
%si n!=711 && m!=498 | ||
%cambiar el condicional, ya que no se sabe cuales son las capas que | ||
%corresponden,esto en caso de que salga error de calclula en esta ocasion | ||
if ~strcmp(char(banda),'B8') | ||
I(:,:,capa)=IMc; | ||
else | ||
%'guardar nueva imagen cortada | ||
Rc=Rx; | ||
end | ||
|
||
end | ||
|
||
|
||
%guardar imagen en TIFF con geodatos | ||
filename = [TOTDIR name]; | ||
%imwrite(I,filename,'tif') | ||
%K = mat2gray(IMc); | ||
INFOx.GeoTIFFTags.GeoKeyDirectoryTag.GTRasterTypeGeoKey=1 | ||
geotiffwrite(filename, I, Rc,'GeoKeyDirectoryTag', INFOx.GeoTIFFTags.GeoKeyDirectoryTag); | ||
|
||
end | ||
|
||
toc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
clear | ||
%leer directorio en que se encuentran las imágenes: | ||
BaseDir='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat'; | ||
MatDir='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/Output/ANG006_IMG/Mat_Matlab'; | ||
XYZdata='/home/david/Documents/Proyectos_CEA/CNM008/Codigo_Mat/Output/ANG006_IMG' | ||
cd(MatDir); | ||
Proyecto='ANG006'; | ||
[A lista]=unix(['find -name "*.mat"']); | ||
RutaLog=[BaseDir,'/Logs']; | ||
archivos_MAT=['archivos_MAT_' Proyecto '.txt']; | ||
%se crea archivo txt con listado de .mat del grupo | ||
FID=fopen([RutaLog,'/',archivos_MAT],'w+'); | ||
fprintf(FID,lista); | ||
fclose(FID); | ||
%se lee el archivo anterior | ||
charMAT='_.mat'; | ||
fid=fopen([RutaLog,'/',archivos_MAT],'r'); | ||
MAT=0 | ||
MATset={}; | ||
while ~feof(fid) | ||
leer_linea=fgetl(fid); | ||
cola=leer_linea(end-3:end); | ||
ArchivoMat=leer_linea(3:end); | ||
%cargar archivo .mat | ||
PathMat=[MatDir '/' ArchivoMat]; | ||
load(PathMat); | ||
names = fieldnames(IndiceVegetacion); | ||
[n,m]=size(names); | ||
%ver que no tenga ceros all(indice(:))==1 | ||
for i=1:n | ||
indicename= char( names( i ) ); | ||
indice=getfield(IndiceVegetacion, indicename); | ||
if all(indice(:))==1 | ||
% FileName= INFO.nir.Filename | ||
NameFile=[ArchivoMat(1:end-4) '_' indicename]; | ||
p=R.nir.DeltaX; | ||
XLimWorld=R.nir.XLimWorld; | ||
YLimWorld=R.nir.YLimWorld; | ||
[v_iv,v_lat,v_lon]=map2vector(indice,p,XLimWorld,YLimWorld); | ||
GEO_data=map_vector2ascii(v_iv,v_lat,v_lon,XYZdata,NameFile); | ||
end | ||
end | ||
|
||
|
||
%se descomprime aqui el archivo (dentro de carpeta) | ||
end | ||
fclose(fid); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function GEO_data=map_vector2ascii(v_iv,v_lat,v_lon,Dir,NameFile) | ||
v_iv=v_iv'; | ||
v_lat=v_lat'; | ||
v_lon=v_lon'; | ||
ID=[1:length(v_iv)]'; | ||
GEO_data=[ID,v_iv,v_lat,v_lon]; | ||
dlmwrite([Dir '/XYZDAT/' NameFile '.dat'],GEO_data); | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
function S_shape=vector2shape(v_iv,v_lon,v_lat,Namefile,Corte) | ||
|
||
%comprimir a solo valores <0 en indice NDVI | ||
[I,J]=find(v_iv<Corte);%usar J que entrega todos los índices en que ocurre | ||
r=1; | ||
for i=1:length(v_iv) | ||
if isempty(find(J==i)) | ||
short_v_iv(r)=v_iv(i); | ||
short_v_lon(r)=v_lon(i); | ||
short_v_lat(r)=v_lat(i); | ||
r=1+r; | ||
end | ||
end | ||
S_shape = struct('Geometry', 'Multipoint', 'id', num2cell(v_iv), 'X', num2cell(v_lon), 'Y', num2cell(v_lat)); | ||
shapewrite(S_shape, Namefile); | ||
|
||
end |