I have first to say, that I’m a newbie when it comes to geo-related stuff, so please excuse me if I ask or formulate something stupid here, but I’ve been biting my teeth out on this problem for hours.
First a little context: I have a table with coordinates in EPSG:3035 and two different shapefiles, the first one is for all of Germany, and if a coordinate is in Berlin, I want the exact district. The shapefiles have different coordinate systems. After some back and forth I was in favor of the first one (germany), but the same methodology produces an error with the berlin shapefile. Here is the MWE with additional comments.
import GeoIO: LatLon, Point, load
# First download the shapefiles used in the MWE and unzip it
# (unzip must be installed on the system)
zipfile = download("https://box.fu-berlin.de/s/wk9ixTJGoHgWSA5/download/shapefiles.zip")
run(`unzip $(zipfile) -d /tmp`)
# the first shapefile uses EPSG:25832 projection and extract the area
# of the first row of the geotable
germany = load("/tmp/kfz250.utm32s/KFZ250.shp")
g_area = germany[1, :geometry]
# we create a point in this projection and can check if this point is
# inside the area
@assert (Point(3.2e5, 5.4e6) in g_area) == false
@assert (Point(3.7302e5, 5.612e6) in g_area) == true
# we try to do the same with another shapefile, which is in CRS84
berlin = load("/tmp/bezirksgrenzen_berlin.shp.zip")
b_area = berlin[1, :geometry]
# when we create a point in CRS84 using LatLon and check if this is in the area
# this will raise this error:
# ERROR: MethodError: no method matching iterate(::Meshes.PolyArea{Meshes.🌐, CoordRefSystems.GeodeticLatLon{…}, Meshes.Ring{…}, Vector{…}})
LatLon(52.5, 13) in b_area
So my question is: Why is the in
function call working for the first shapefile but not for the second? And how can I fix this?
Thank you,
Steffen