Skip to content

Commit

Permalink
Use gatsby v4 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
diegovalle committed Sep 11, 2024
1 parent 11be689 commit 1e40183
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
21 changes: 14 additions & 7 deletions R/src/update_municipio_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ new_muns <- setdiff(unique(df21$Cve..Municipio), unique(df20$Cve..Municipio))
unique(df[which(df$Cve..Municipio %in% new_muns), ]$Municipio)


df=read.csv("../clean/data/municipio_names.csv", fileEncoding = "windows-1252") %>%
filter(mun_code < 900)
df_mun_names=read.csv("../clean/data/municipio_names.csv", fileEncoding = "windows-1252")
df_mun_names$id <- as.numeric(str_mxmunicipio(df_mun_names$state_code, df_mun_names$mun_code))
##
df_d <- read.csv("../clean/snsp-data/Municipal-Delitos-2015-2022_ene2022/Municipal-Delitos-2015-2022_ene2022.csv", fileEncoding = "windows-1252")
df_lates_crime_data <- read.csv("../clean/snsp-data/municipios.csv", fileEncoding = "windows-1252")

df_d <- df_d[, c("Municipio", "Cve..Municipio")]
df_d <- df_d %>%
df_lates_crime_data <- df_lates_crime_data[, c("Municipio", "Cve..Municipio")]
df_lates_crime_data <- df_lates_crime_data %>%
unique() %>%
arrange(Cve..Municipio)

df$id <- as.numeric(str_mxmunicipio(df$state_code, df$mun_code))

setdiff(df_d$Cve..Municipio, df$id)
# municipios that are in the latest crime data but not in the municipio names
setdiff(df_lates_crime_data$Cve..Municipio, df_mun_names$id)
setdiff(df_mun_names$id, df_lates_crime_data$Cve..Municipio)

df_population <- read.csv("../clean/data/pop_muns.csv")
df_population$id <- as.numeric(str_mxmunicipio(df_population$state_code, df_population$mun_code))

# municipios that are in the latest crime data but not in the conapo population
setdiff(df_population$id, df_mun_names$id)
2 changes: 1 addition & 1 deletion build_website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ cp R/interactive-map/municipios*.json elcri.men/static/elcrimen-json/

export GATSBY_TELEMETRY_DISABLED=1
(cd elcri.men && npx browserslist@latest --update-db)
(cd elcri.men && npm install && gatsby build --verbose)
(cd elcri.men && rm node_modules && gatsby clean && npm install && gatsby build --verbose)

echo "Exporting databases to csv.gz"
# Export the sqlite database to csv and compress
Expand Down
1 change: 1 addition & 0 deletions clean/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def write_mun_db(conn, CSV_MUNICIPIOS):
print("Writing municipio data to db")
for i in crime_municipios.years:
print("Writing year: " + i)
import pdb; pdb.set_trace()
pd_sql.to_sql(crime_municipios.get_filtered_data(i, os.path.join('snsp-data', CSV_MUNICIPIOS)), 'municipios_fuero_comun', conn, if_exists='append', index=False, chunksize=1000000)
print("End writing municipio data to db")

Expand Down

0 comments on commit 1e40183

Please sign in to comment.