instrucciones

parent 41d6ecf3
# Cuantificación del Espacio Público al Aire Libre de los Municipios Metropolitanos en la República Mexicana Utilizando OpenStreetMaps
## INEGI
## Descaga de datos
'''
cd data/inegi
sh download.sh
'''
## OSM
#sudo apt install gdal-bin
echo "Marco Geoestadístico Nacional"
mgn2024="794551132173_s.zip"
if [ ! -e "$mgn2024" ]; then
wget "https://www.inegi.org.mx/contenidos/productos/prod_serv/contenidos/espanol/bvinegi/productos/geografia/marcogeo/"$mgn2024
else
echo $mgn2024 "descargado"
fi
# Manzanas
if [ ! -e "mgn2024/00m.shp" ]; then
mkdir -p mgn2024
unzip -nj $mgn2024 -d mgn2024/
cd mgn2024
mkdir 00m
for filename in *.zip; do
cvegeo=${filename%_*}
unzip -nj $filename "conjunto_de_datos/"$cvegeo"m.*" -d 00m
done
unzip -nj mg_2024_integrado.zip -d mg_2024
cd 00m
ogrmerge -single -o ../mg_2024/00m.shp *.shp
cd ../..
rm -r mgn2024/00m
rm mgn2024/*.zip
mv mgn2024/mg_2024/*.* mgn2024/
rm -r mgn2024/mg_2024
else
echo "00m.shp created"
fi
#===============================================================================
#===============================================================================
echo "Censo de Población y Vivienda 2020"
mkdir -p ccpv/csv
censo2020="iter_00_cpv2020_csv.zip"
if [ ! -e "$censo2020" ]; then
wget "https://www.inegi.org.mx/contenidos/programas/ccpv/2020/datosabiertos/iter/"$censo2020
else
echo $censo2020 "descargado"
fi
unzip -nj $censo2020 iter_00_cpv2020/conjunto_de_datos/conjunto_de_datos_iter_00CSV20.csv -d ccpv/
#cat ccpv/conjunto_de_datos_iter_00CSV20.csv | grep -v "Total" >> "ccpv/"$outputfile
#AGEB
for i in $(seq 32); do
value=$(printf "%02d" $i)
mainname="ageb_mza_urbana_"$value"_cpv2020"
filename=$mainname"_csv.zip"
if [ ! -e "ccpv/$filename" ]; then
wget "https://www.inegi.org.mx/contenidos/programas/ccpv/2020/datosabiertos/ageb_manzana/"$filename
mv $filename ccpv/$filename
else
echo $filename "descargado"
fi
unzip -nj ccpv/$filename $mainname"/conjunto_de_datos/conjunto_de_datos_ageb_urbana_"$value"_cpv2020.csv" -d ccpv/csv
done
#head -1 director/one_file.csv > output.csv ## writing the header to the final file
outputfile="ageb_mza_urbana_cpv2020.csv"
if [ ! -e "ccpv/$outputfile" ]; then
for filename in "ccpv/csv/*.csv"; do
echo $filename
if [ ! -e "ccpv/$outputfile" ]; then
cat $filename | grep -v "Total" >> "ccpv/"$outputfile ## writing the content of all csv starting with second line into final file
else
cat $filename | grep -v "Total" | tail -n +2 >> "ccpv/"$outputfile ## writing the content of all csv starting with second line into final file
fi
done
rm -r ccpv/csv
else
echo $outputfile created
fi
#tail -n +2 director/*.csv >> output.csv ## writing the content of all csv starting with second line into final file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment