marcbosch
marcbosch

Reputation: 81

GeoJSON.jl reading some geometries incorrectly

I am trying to read a census tract map of Barcelona from a vector layer that contains, from larger to smaller, Neighbourhoods, Districts, and Census tracts. However, the census tract geometries appear to be wrong. There's nothing wrong with the file itself as I've used it in R. The code in R to filter and plot the census tracts is as follows.

library(sf)
library(tmap)
bcn <- st_read("/home/marc/Documents/30dayMapChallenge/data/adm_units/0301100100_UNITATS_ADM_POLIGONS.json")
sc <- bcn[bcn$SEC_CENS != "-",]
qtm(sc, fill = "Barri")

R plot

In Julia, I'm using the following code

using DataFrames
using SpatialDependence
using GeoJSON
using Plots
jsonbytes = read("/home/marc/Documents/30dayMapChallenge/data/adm_units/0301100100_UNITATS_ADM_POLIGONS.json")
secc = GeoJSON.read(jsonbytes)

seccdf = DataFrame(secc)
# keep only census tracts
seccdf = filter(:SEC_CENS => !=("-"),seccdf)
plot(seccdf,:BARRI, Unique())

It returns the following Julia plot

However, if I do

seccdf = filter(:CONJ_DESCR => !=("Barris"),seccdf)
plot(seccdf,:BARRI, Unique())

It returns the correct geometries for the neighbourhoods.

Data is downloaded from here: https://opendata-ajuntament.barcelona.cat/data/ca/dataset/20170706-districtes-barris/resource/cd800462-f326-429f-a67a-c69b7fc4c50a

Upvotes: 0

Views: 71

Answers (1)

marcbosch
marcbosch

Reputation: 81

Solved: it has to do with the projection. Apparently this library doesn't read layers in projected CRS, such as this one.

Upvotes: 0

Related Questions