Skip to content

Commit

Permalink
Merge pull request #9 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
santiago123x authored Jun 21, 2024
2 parents e25a91f + 722dd31 commit 3c49a30
Show file tree
Hide file tree
Showing 30 changed files with 338 additions and 40 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
venv

env
__pycache__
temp_files
outputs
files
files
outputs_2
outputs_test
Binary file added data/data/instituteLogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions data/data/ranges/HGT_ Titulo de HGT.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
7 changes: 7 additions & 0 deletions data/data/ranges/T2_Temperatura °C.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
7 changes: 7 additions & 0 deletions data/data/ranges/V10_Titulo V10.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
7 changes: 7 additions & 0 deletions data/data/ranges/WS10m_Titulo de WS10m.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
7 changes: 7 additions & 0 deletions data/data/ranges/ranges.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
min,max,color
0,1,#FFFFFF
1,600,#0000FF
601,800,#CA976D
801,900,#FF00FF
901,1200,#EABC8E
1201,inf,#FF8000
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["WGS_1984_UTM_Zone_16N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-87.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["WGS_1984_UTM_Zone_16N",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-87.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
117 changes: 117 additions & 0 deletions data/shapefile/limites_municipales_2001/limite_municipal_2001.shp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE metadata SYSTEM "http://www.fgdc.gov/metadata/fgdc-std-001-1998.dtd">
<metadata>
<idinfo>
<citation>
<citeinfo>
<origin>REQUIRED: The name of an organization or individual that developed the data set.</origin>
<pubdate>REQUIRED: The date when the data set is published or otherwise made available for release.</pubdate>
<title>Municipios - Censo 2001</title>
<geoform Sync="TRUE">vector digital data</geoform>
<onlink Sync="TRUE">\\NKMARTINEZ-PC\C$\MAPAS SEPLAN\SINIT SHAPE\m1103vA002001_HN.shp</onlink>
<ftname Sync="TRUE">m1103vA002001_HN</ftname></citeinfo>
</citation>
<descript>
<abstract>Límites de los 298 Municipios de la República de Honduras (año 2001) generados a partir del mapa de aldeas que fue digitalizado a partir de los mapas de los segmentos censales de 1988 de la Dirección General de Estadísticas y Censos.

Para obtener los municipios al año del censo de población y vivienda de 2001, al mapa generado se le actualizaron los límites de nuevos municipios creados en el período de 1988 - 2001.</abstract>
<purpose>Mostrar los límites municipales para correlacionarlos con los datos de los censos de población y vivienda de 2001.</purpose>
<langdata Sync="TRUE">es</langdata></descript>
<timeperd>
<timeinfo>
<sngdate>
<caldate>REQUIRED: The year (and optionally month, or month and day) for which the data set corresponds to the ground.</caldate>
</sngdate>
</timeinfo>
<current>REQUIRED: The basis on which the time period of content information is determined.</current>
</timeperd>
<status>
<progress>REQUIRED: The state of the data set.</progress>
<update>REQUIRED: The frequency with which changes and additions are made to the data set after the initial data set is completed.</update>
</status>
<spdom>
<bounding>
<westbc Sync="TRUE">-89.379870</westbc>
<eastbc Sync="TRUE">-83.121866</eastbc>
<northbc Sync="TRUE">16.519924</northbc>
<southbc Sync="TRUE">12.955059</southbc>
</bounding>
<lboundng><leftbc Sync="TRUE">245963.444200</leftbc><rightbc Sync="TRUE">914181.427000</rightbc><bottombc Sync="TRUE">1435261.438600</bottombc><topbc Sync="TRUE">1826447.901000</topbc></lboundng></spdom>
<keywords>
<theme>
<themekt>REQUIRED: Reference to a formally registered thesaurus or a similar authoritative source of theme keywords.</themekt>
<themekey>municipios</themekey>
<themekey>límites municipales</themekey><themekey>municipalities</themekey><themekey>municipal boundaries</themekey></theme>
</keywords>
<accconst>REQUIRED: Restrictions and legal prerequisites for accessing the data set.</accconst>
<useconst>REQUIRED: Restrictions and legal prerequisites for using the data set after access is granted.</useconst>
<native Sync="TRUE">Microsoft Windows Vista Version 6.1 (Build 7600) ; ESRI ArcCatalog 9.3.0.1770</native>
<natvform Sync="TRUE">Shapefile</natvform></idinfo>
<spdoinfo>
<direct Sync="TRUE">Vector</direct>
<ptvctinf>
<sdtsterm Name="m1103vA002001_HN">
<sdtstype Sync="TRUE">G-polygon</sdtstype>
<ptvctcnt Sync="TRUE">0</ptvctcnt>
</sdtsterm>
<esriterm Name="m1103vA002001_HN"><efeatyp Sync="TRUE">Simple</efeatyp><efeageom Sync="TRUE">Polygon</efeageom><esritopo Sync="TRUE">FALSE</esritopo><efeacnt Sync="TRUE">0</efeacnt><spindex Sync="TRUE">FALSE</spindex><linrefer Sync="TRUE">FALSE</linrefer></esriterm></ptvctinf>
</spdoinfo>
<eainfo>
<detailed Name="m1103vA002001_HN">
<enttyp>
<enttypl Sync="TRUE">m1103vA002001_HN</enttypl>
<enttypt Sync="TRUE">Feature Class</enttypt><enttypc Sync="TRUE">0</enttypc></enttyp>
<attr><attrlabl Sync="TRUE">FID</attrlabl><attalias Sync="TRUE">FID</attalias><attrtype Sync="TRUE">OID</attrtype><attwidth Sync="TRUE">4</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale><attrdef Sync="TRUE">Internal feature number.</attrdef><attrdefs Sync="TRUE">ESRI</attrdefs><attrdomv><udom Sync="TRUE">Sequential unique whole numbers that are automatically generated.</udom></attrdomv></attr><attr>
<attrlabl>Shape</attrlabl>
<attrdef>Feature geometry.</attrdef>
<attrdefs>ESRI</attrdefs>
<attrdomv>
<udom>Coordinates defining the features.</udom>
</attrdomv>
<attalias Sync="TRUE">Shape</attalias><attrtype Sync="TRUE">Geometry</attrtype><attwidth Sync="TRUE">0</attwidth><atprecis Sync="TRUE">0</atprecis><attscale Sync="TRUE">0</attscale></attr>
<attr>
<attrlabl>NOMBRE</attrlabl>
<attalias Sync="TRUE">NOMBRE</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">50</attwidth></attr>
<attr>
<attrlabl>COD_MUNI</attrlabl>
<attalias Sync="TRUE">COD_MUNI</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">16</attwidth></attr>
<attr><attrlabl Sync="TRUE">DEP</attrlabl><attalias Sync="TRUE">DEP</attalias><attrtype Sync="TRUE">Number</attrtype><attwidth Sync="TRUE">4</attwidth></attr><attr><attrlabl Sync="TRUE">MUN</attrlabl><attalias Sync="TRUE">MUN</attalias><attrtype Sync="TRUE">Number</attrtype><attwidth Sync="TRUE">4</attwidth></attr><attr><attrlabl Sync="TRUE">COD_MUN_</attrlabl><attalias Sync="TRUE">COD_MUN_</attalias><attrtype Sync="TRUE">Number</attrtype><attwidth Sync="TRUE">4</attwidth></attr><attr><attrlabl Sync="TRUE">CODPAIS</attrlabl><attalias Sync="TRUE">CODPAIS</attalias><attrtype Sync="TRUE">String</attrtype><attwidth Sync="TRUE">2</attwidth></attr><attr><attrlabl Sync="TRUE">Shape_Leng</attrlabl><attalias Sync="TRUE">Shape_Leng</attalias><attrtype Sync="TRUE">Float</attrtype><attwidth Sync="TRUE">19</attwidth><atnumdec Sync="TRUE">11</atnumdec></attr><attr>
<attrlabl>Shape_Area</attrlabl>
<attrdef>Area of feature in internal units squared.</attrdef>
<attrdefs>ESRI</attrdefs>
<attrdomv>
<udom>Positive real numbers that are automatically generated.</udom>
</attrdomv>
<attalias Sync="TRUE">Shape_Area</attalias><attrtype Sync="TRUE">Float</attrtype><attwidth Sync="TRUE">19</attwidth><atnumdec Sync="TRUE">11</atnumdec></attr>
<attr><attrlabl Sync="TRUE">Km2</attrlabl><attalias Sync="TRUE">Km2</attalias><attrtype Sync="TRUE">Float</attrtype><attwidth Sync="TRUE">13</attwidth><atnumdec Sync="TRUE">11</atnumdec></attr><attr><attrlabl Sync="TRUE">Densidad</attrlabl><attalias Sync="TRUE">Densidad</attalias><attrtype Sync="TRUE">Float</attrtype><attwidth Sync="TRUE">13</attwidth><atnumdec Sync="TRUE">11</atnumdec></attr></detailed>
</eainfo>
<distinfo>
<resdesc>Downloadable Data</resdesc>
<stdorder><digform><digtinfo><transize Sync="TRUE">0.000</transize><dssize Sync="TRUE">0.000</dssize></digtinfo></digform></stdorder></distinfo>
<metainfo>
<metd Sync="TRUE">20100810</metd>
<metc>
<cntinfo>
<cntperp>
<cntper>Abner Jimenez</cntper>
<cntorg>REQUIRED: The organization responsible for the metadata information.</cntorg>
</cntperp>
<cntaddr>
<addrtype>REQUIRED: The mailing and/or physical address for the organization or individual.</addrtype>
<city>REQUIRED: The city of the address.</city>
<state>REQUIRED: The state or province of the address.</state>
<postal>REQUIRED: The ZIP or other postal code of the address.</postal>
</cntaddr>
<cntvoice>REQUIRED: The telephone number by which individuals can speak to the organization or individual.</cntvoice>
<cntemail>abnerjhn@gmail.com</cntemail>
</cntinfo>
</metc>
<metstdn Sync="TRUE">FGDC Content Standards for Digital Geospatial Metadata</metstdn>
<metstdv Sync="TRUE">FGDC-STD-001-1998</metstdv>
<mettc Sync="TRUE">local time</mettc>
<metextns>
<onlink>http://www.esri.com/metadata/esriprof80.html</onlink>
<metprof>ESRI Metadata Profile</metprof>
</metextns>
<langmeta Sync="TRUE">es</langmeta><metextns><onlink Sync="TRUE">http://www.esri.com/metadata/esriprof80.html</onlink><metprof Sync="TRUE">ESRI Metadata Profile</metprof></metextns></metainfo>
<Esri><MetaID>{5E699541-F233-41F3-8D9E-2028AFDF7567}</MetaID><CreaDate>20091122</CreaDate><CreaTime>09122300</CreaTime><SyncOnce>FALSE</SyncOnce><SyncDate>20100810</SyncDate><SyncTime>15185200</SyncTime><ModDate>20100810</ModDate><ModTime>15185200</ModTime><DataProperties><lineage><Process ToolSource="C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Data Management Tools.tbx\CopyFeatures" Date="20100810" Time="151859">CopyFeatures C:\SINIT\SINIT\SINIT.mdb\m1103vA002001_HN "C:\MAPAS SEPLAN\SINIT SHAPE\m1103vA002001_HN.shp" # 0 0 0</Process></lineage></DataProperties></Esri><dataqual><lineage><procstep><procdesc Sync="TRUE">Metadata imported.</procdesc><srcused Sync="TRUE">C:\NUEVO_SINIT\metadata-aldeas.xml</srcused><procdate Sync="TRUE">20091122</procdate><proctime Sync="TRUE">09122300</proctime></procstep></lineage></dataqual><dataIdInfo><envirDesc Sync="TRUE">Microsoft Windows Vista Version 6.1 (Build 7600) ; ESRI ArcCatalog 9.3.0.1770</envirDesc><dataLang><languageCode Sync="TRUE" value="es"></languageCode></dataLang><idCitation><resTitle Sync="TRUE">m1103vA002001_HN</resTitle><presForm><PresFormCd Sync="TRUE" value="005"></PresFormCd></presForm></idCitation><spatRpType><SpatRepTypCd Sync="TRUE" value="001"></SpatRepTypCd></spatRpType><dataExt><geoEle><GeoBndBox esriExtentType="native"><westBL Sync="TRUE">245963.4442</westBL><eastBL Sync="TRUE">914181.427</eastBL><northBL Sync="TRUE">1826447.901</northBL><southBL Sync="TRUE">1435261.4386</southBL><exTypeCode Sync="TRUE">1</exTypeCode></GeoBndBox></geoEle></dataExt><geoBox esriExtentType="decdegrees"><westBL Sync="TRUE">-89.37987</westBL><eastBL Sync="TRUE">-83.121866</eastBL><northBL Sync="TRUE">16.519924</northBL><southBL Sync="TRUE">12.955059</southBL><exTypeCode Sync="TRUE">1</exTypeCode></geoBox></dataIdInfo><mdLang><languageCode Sync="TRUE" value="es"></languageCode></mdLang><mdStanName Sync="TRUE">ISO 19115 Geographic Information - Metadata</mdStanName><mdStanVer Sync="TRUE">DIS_ESRI1.0</mdStanVer><mdChar><CharSetCd Sync="TRUE" value="004"></CharSetCd></mdChar><mdHrLv><ScopeCd Sync="TRUE" value="005"></ScopeCd></mdHrLv><mdHrLvName Sync="TRUE">dataset</mdHrLvName><distInfo><distributor><distorTran><onLineSrc><orDesc Sync="TRUE">002</orDesc><linkage Sync="TRUE">file://\\NKMARTINEZ-PC\C$\MAPAS SEPLAN\SINIT SHAPE\m1103vA002001_HN.shp</linkage><protocol Sync="TRUE">Local Area Network</protocol></onLineSrc><transSize Sync="TRUE">0.000</transSize></distorTran><distorFormat><formatName Sync="TRUE">Shapefile</formatName></distorFormat></distributor></distInfo><spref><horizsys><cordsysn><geogcsn Sync="TRUE">GCS_WGS_1984</geogcsn><projcsn Sync="TRUE">WGS_1984_UTM_Zone_16N</projcsn></cordsysn><planar><planci><plance Sync="TRUE">coordinate pair</plance><plandu Sync="TRUE">meters</plandu><coordrep><absres Sync="TRUE">0.000000</absres><ordres Sync="TRUE">0.000000</ordres></coordrep></planci><gridsys><gridsysn Sync="TRUE">Universal Transverse Mercator</gridsysn><utm><utmzone Sync="TRUE">16</utmzone><transmer><sfctrmer Sync="TRUE">0.999600</sfctrmer><longcm Sync="TRUE">-87.000000</longcm><latprjo Sync="TRUE">0.000000</latprjo><feast Sync="TRUE">500000.000000</feast><fnorth Sync="TRUE">0.000000</fnorth></transmer></utm></gridsys></planar><geodetic><horizdn Sync="TRUE">D_WGS_1984</horizdn><ellips Sync="TRUE">WGS_1984</ellips><semiaxis Sync="TRUE">6378137.000000</semiaxis><denflat Sync="TRUE">298.257224</denflat></geodetic></horizsys></spref><refSysInfo><RefSystem><refSysID><identCode Sync="TRUE">WGS_1984_UTM_Zone_16N</identCode></refSysID></RefSystem></refSysInfo><spatRepInfo><VectSpatRep><topLvl><TopoLevCd Sync="TRUE" value="001"></TopoLevCd></topLvl><geometObjs Name="m1103vA002001_HN"><geoObjTyp><GeoObjTypCd Sync="TRUE" value="001"></GeoObjTypCd></geoObjTyp><geoObjCnt Sync="TRUE">0</geoObjCnt></geometObjs></VectSpatRep></spatRepInfo><mdDateSt Sync="TRUE">20100810</mdDateSt></metadata>
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/postprocessing/cut_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ def cut_rasters(raster_filename, shp_path):
dest.write(out_image)

os.remove(raster_filename)

return raster_filename.replace(os.path.basename(raster_filename), os.path.basename(raster_filename).replace("_raster",""))
27 changes: 23 additions & 4 deletions src/postprocessing/export_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
from rasterio.transform import from_origin
import os
from .cut_map import cut_rasters
from .generate_images import generate_image
import matplotlib.pyplot as plt
from datetime import datetime, timedelta


def export_raster(dataset, file_name, specific_variable, output_path, shp_path, is4Dim=False):
def export_raster(dataset, file_name, specific_variable, output_path, inputs_path, is4Dim=False):

# Get the current script directory
output_path_folder = os.path.join(output_path, file_name)
shp_path = os.path.join(shp_path, "limite_nacional_2011", "limite_nacional_2011.shp")
shape_path = os.path.join(inputs_path, "shapefile")
data_path = os.path.join(inputs_path, "data")
shp_path = os.path.join(shape_path, "limite_nacional_2011", "limite_nacional_2011.shp")

if not os.path.exists(output_path):
os.makedirs(output_path)
Expand Down Expand Up @@ -92,10 +95,26 @@ def export_raster(dataset, file_name, specific_variable, output_path, shp_path,

print(f"Raster for: {specific_variable} day: {date} created successfully")

cut_rasters(raster_filename, shp_path)
new_raster_filename = cut_rasters(raster_filename, shp_path)

print(f"Raster for: {specific_variable} day: {date} cut successfully as '{raster_filename}'")
print(f"Raster for: {specific_variable} day: {date} cut successfully as '{new_raster_filename}'")

generate_image(new_raster_filename, search_csv(os.path.join(data_path,"ranges"), specific_variable), data_path, os.path.join(shape_path, "limites_municipales_2001", "limite_municipal_2001.shp"))

return var_output



def search_csv(ranges_path, varname):

csvs = [os.path.join(ranges_path, file) for file in os.listdir(ranges_path)]

def contains_keyword(file_name, keyword):
return file_name.startswith(keyword)

filtered_files = [file for file in csvs if contains_keyword(os.path.basename(file), varname)]

if not filtered_files:
filtered_files.append(os.path.join(ranges_path, "ranges_Default.csv"))

return filtered_files[0]
Loading

0 comments on commit 3c49a30

Please sign in to comment.