Git Product home page Git Product logo

Comments (7)

visr avatar visr commented on May 29, 2024

The geometry is in the first column and the points do not appear explicitly but only says:
Geometry: wkbPoint

This is due to changes in ArchGDAL since the readme what written. The order of the columns has no meaning and the geometry is only a matter of the show method I believe, not the actual content. Would be great if you could update the readme to what it looks like now though, since it would be less confusing.

The other questions is if I can use GeoDataFrames to merge a shapefile with a data frame when both
objects have a column in common. I want to preserve all the shapefile geometric structure.

See also my link to the DataFrames join method in JuliaGeo/Shapefile.jl#56 (comment). This package directly returns a DataFrame, so you can use this directly. The geometries will stay intact.

from geodataframes.jl.

martinmestre avatar martinmestre commented on May 29, 2024

Thank you very much Martin @visr !
Ok, I will try to update the README file. Should I use the git command for that?

Regarding the other problem, this is what I want to do (GDF=GeoDataFrames):

graph_file="input.shp"
state_data = GDF.read(graph_file)
assignment = DataFrame(CSV.File(assignment_file))
graph_data = outerjoin(state_data,assignment, on = "GEOID20")
graph = BaseGraph(graph_data, population_col)

But the code gives error when reading the input file:

LoadError: MethodError: Cannot convert an object of type
ArchGDAL.IGeometry{wkbMultiPolygon} to an object of type
ArchGDAL.IGeometry{wkbPolygon}
Closest candidates are:
convert(::Type{var"#s404"} where var"#s404"<:ArchGDAL.AbstractGeometry, ::GeoFormatTypes.AbstractWellKnownText) at /home/mmestre/.julia/packages/ArchGDAL/erkjx/src/convert.jl:36
convert(::Type{var"#s404"} where var"#s404"<:ArchGDAL.AbstractGeometry, ::GeoFormatTypes.WellKnownBinary) at /home/mmestre/.julia/packages/ArchGDAL/erkjx/src/convert.jl:42
convert(::Type{var"#s404"} where var"#s404"<:ArchGDAL.AbstractGeometry, ::GeoFormatTypes.GeoJSON) at /home/mmestre/.julia/packages/ArchGDAL/erkjx/src/convert.jl:45

Do you have any clue of how to solve this problem ?
Best regards,
Martín

from geodataframes.jl.

visr avatar visr commented on May 29, 2024

Nice, thanks! You could use git, but for small changes I often find it more convenient to click the edit (pencil) button on github; https://github.com/evetion/GeoDataFrames.jl/edit/master/README.md.

Your issues actually looks like this one that came up recently on the ArchGDAL repository: yeesian/ArchGDAL.jl#223

Until that issue is fixed, perhaps you could save your data as GeoPackage and use that instead, since the issue is limited to shapefiles.

from geodataframes.jl.

martinmestre avatar martinmestre commented on May 29, 2024

Thanks @visr !
Could you tell me which changes should be done to the following lines in order to save data to GeoPackage (I do not know how and when should that be done):

graph_file="input.shp"
state_data = GDF.read(graph_file)
assignment = DataFrame(CSV.File(assignment_file))
graph_data = outerjoin(state_data,assignment, on = "GEOID20")
graph = BaseGraph(graph_data, population_col)

from geodataframes.jl.

visr avatar visr commented on May 29, 2024

I think this should work:

df = GDF.read("input.shp")
GDF.write("input.gpkg", df)
state_data = GDF.read("input.gpkg")

It's a good idea to put 3 backticks around your code to make it easier to read by the way. If you write julia after your first 3 backticks it will even apply syntax highlighting.

```julia

from geodataframes.jl.

martinmestre avatar martinmestre commented on May 29, 2024

Thanks @visr,

It seems the problem starts from the begining when reading the file

df = GDF.read("input.shp")

because it gives:

LoadError: MethodError: Cannot `convert` an object of type 
  ArchGDAL.IGeometry{wkbMultiPolygon} to an object of type 
  ArchGDAL.IGeometry{wkbPolygon}

Is there any solution for this?

I have tried to read directly with

state_data=ArchGDAL.read(graph_file)

It works ok for reading, but afterwards I cannot use the command:

graph_data = outerjoin(state_data,assignment, on = "GEOID20")

because it gives:

LoadError: MethodError: no method matching outerjoin(::ArchGDAL.IDataset, ::DataFrame; on="GEOID20")
Closest candidates are:
  outerjoin(::AbstractDataFrame, ::AbstractDataFrame; on, makeunique, source, indicator, validate, renamecols, matchmissing) at /home/mmestre/.julia/packages/DataFrames/pVFzb/src/join/composer.jl:1026
  outerjoin(::AbstractDataFrame, ::AbstractDataFrame, ::AbstractDataFrame...; on, makeunique, validate, matchmissin

Thank you very much,
Martín

from geodataframes.jl.

visr avatar visr commented on May 29, 2024

Ah sorry I missed that it failed on GDF.read. Another way you can convert to a GeoPackage is using the GDAL command line tools, see for instance the last example here: https://github.com/JuliaGeo/GDAL.jl#using-the-gdal-and-ogr-utilities

from geodataframes.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.