Geopandas equivalent?

,

Hi,

I am looking for an equivalent to Geopandas in Julia to load shapefiles as dataframes.

I read about GeoDataFrames.jl but I am having trouble installing it, giving me this error message:

(@v1.6) pkg> add GeoDataFrames
   Resolving package versions...
ERROR: Unsatisfiable requirements detected for package GeoStatsBase [323cb8eb]:

As a bonus question (should probably be a different topic), any package that could plot those shapefiles with a base map (Google map, OSM etc.) would be great

Thanks!
Alex

1 Like

GMT.jl. Plots shapefiles directly over georeferenced images but no particular interface with OSM.

3 Likes

It looks like you’re installing all your packages in the default environment - don’t do this, as it will likely lead to compat issues (as you see) between packages you don’t actually need at the same time, and you’re foregoing the reproducibility benefits of Julia’s lightweight environments and their associated Project and Manifest toml files.

So in short make a folder for the analysis you’re looking to do, activate an environment in that folder, and add the packages you need (in this case it looks like GeoDataFrames and GMT). if that still doesn’t work post the whole error here and we’ll see what we can do.

4 Likes

Thank you for the quick reply

It is a lot cleaner indeed and the installation worked.
I tried this and got an error message:

using GMT, DataFrames, CSV
using GeoDataFrames; const GDF=GeoDataFrames

pts = GDF.read("pts.shp")
ERROR: LoadError: could not load library ""
dlopen(.dylib, 1): image not found
Stacktrace:
 [1] gdalopenex(pszFilename::String, nOpenFlags::Int64, papszAllowedDrivers::Ptr{Cstring}, papszOpenOptions::Ptr{Cstring}, papszSiblingFiles::Ptr{Cstring})
   @ GDAL ~/.julia/packages/GDAL/5CClC/src/gdal_h.jl:472
 [2] #read#139
   @ ~/.julia/packages/ArchGDAL/erkjx/src/dataset.jl:441 [inlined]
 [3] read
   @ ~/.julia/packages/ArchGDAL/erkjx/src/dataset.jl:441 [inlined]
 [4] read(fn::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/43O9q/src/io.jl:40
 [5] read(fn::String)
   @ GeoDataFrames ~/.julia/packages/GeoDataFrames/43O9q/src/io.jl:40
 [6] top-level scope
   @ ~/Documents/Github/Sajag_Nepal/flowR_model/Display_shapefile_and_output_csv.jl:4
in expression starting at /Users/alexdunant/Documents/Github/Sajag_Nepal/flowR_model/Display_shapefile_and_output_csv.jl:4

Thanks joa-quim - GMT looks pretty great for nice looking maps!

This is odd, why is the library string here empty? Is this using the latest GDAL.jl? Perhaps it’s good to file an issue at the GDAL.jl repo, with the output of ] st -m and your versioninfo().

Meanwhile you could also try out GitHub - JuliaEarth/GeoTables.jl: Geospatial tables for the GeoStats.jl framework, which by default loads shapefiles using Shapefile.jl (not GDAL). Then you can plot the geometries with GitHub - JuliaGeometry/MeshViz.jl: Makie.jl recipes for visualization of Meshes.jl.

2 Likes

Sorry if we confuse you with all the alternatives (I would get confused) but you can read your shapefile with

D = gmtread("pts.shp");

and get the data in a GMTdaset type. I would like one day to make an interface between this type and others mentioned above but so far I need data in that type to communicate with the GMT library.