Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write to shapefile #15

Merged
merged 10 commits into from
May 4, 2023
Merged

write to shapefile #15

merged 10 commits into from
May 4, 2023

Conversation

ErickChacon
Copy link
Member

@ErickChacon ErickChacon commented May 3, 2023

PR to be able to export to shapefile using Shapefile.jl and improve geointerface functionality. Whem geometries are Multi, exporting to .shp is quite easy with SHP.write(fname, geotable), otherwise we need to convert to Multi and then write.

src/GeoTables.jl Outdated Show resolved Hide resolved
src/GeoTables.jl Outdated Show resolved Hide resolved
src/GeoTables.jl Outdated Show resolved Hide resolved
@ErickChacon
Copy link
Member Author

@juliohm I started a discussion in Shapefile.jl, let's see what they say. I will also like to be able to write to other formats using ArchGDAL. Should I start that in a separate PR? I think we can use something similar to GeoDataFrames.jl:

https://github.com/evetion/GeoDataFrames.jl/blob/fec887c71124adf1dd11c33878ed6186aba10bd3/src/io.jl#L73C1-L164

Let me know your thoughts.

@juliohm
Copy link
Member

juliohm commented May 3, 2023

Thank you @ErickChacon for these great additions. Can you explain why our save doesn't cover the ArchGDAL.jl case? If we pass a geotable with geometry column following the GeoInterface.jl shouldn't ArchGDAL.jl provide a similar AG.write function?

README.md Outdated Show resolved Hide resolved
ErickChacon and others added 2 commits May 3, 2023 15:14
Co-authored-by: Júlio Hoffimann <julio.hoffimann@gmail.com>
@ErickChacon
Copy link
Member Author

Thank you @ErickChacon for these great additions. Can you explain why our save doesn't cover the ArchGDAL.jl case? If we pass a geotable with geometry column following the GeoInterface.jl shouldn't ArchGDAL.jl provide a similar AG.write function?

Last time I checked it, there was no functionality to write from a table. I needed to manually convert a table to an ArchGDAL dataset iterating over rows to push features. I will check if this has been improved.

@juliohm
Copy link
Member

juliohm commented May 3, 2023

That would be great. Maybe it is another situation where we need to fix the issue upstream in ArchGDAL.jl, adding a write function there before coming back here. This is a good exercise to improve the status of these loaders.

@ErickChacon
Copy link
Member Author

That would be great. Maybe it is another situation where we need to fix the issue upstream in ArchGDAL.jl, adding a write function there before coming back here. This is a good exercise to improve the status of these loaders.

Just to let you know that there is an attempt at yeesian/ArchGDAL.jl#243 to create an IFeatureLayer from a Table. Once something like that is merged, we could easily use ArchGDAL to export to other format types.

With respect to Shapefile.jl, I started an issue, should we accept our current fix until that issue is solved? Or should we keep the adequate code (removing the conditional lines) and accepting that an error will be thrown when attempting to write a Chain and PolyArea to a .shp file?

@juliohm
Copy link
Member

juliohm commented May 3, 2023 via email

@juliohm
Copy link
Member

juliohm commented May 3, 2023

Do we need more tests for the save functionality?

@juliohm
Copy link
Member

juliohm commented May 3, 2023

I am wondering why our tests are failing only on GitHub Actions. Any clue why the HTTP requests are failing from GADM.jl?

@ErickChacon
Copy link
Member Author

ErickChacon commented May 4, 2023

Do we need more tests for the save functionality?

Yes, I forgot about it. Should I do it similar to the existing test with "geojson"?

@ErickChacon
Copy link
Member Author

I am wondering why our tests are failing only on GitHub Actions. Any clue why the HTTP requests are failing from GADM.jl?

No, I haven't checked it. I will check it.

@juliohm
Copy link
Member

juliohm commented May 4, 2023

Should I do it similar to the existing test with "geojson"?

That would be great, but feel free to add other tests you have in mind too.

@juliohm
Copy link
Member

juliohm commented May 4, 2023

I've updated the test/Project.toml in GADM.jl to see if the issue was coming from there, and learned that ArchGDAL.jl is not even building there in GitHub Actions: JuliaGeo/GADM.jl#49

I really dislike the whole GDAL experience, so full of issues...

@ErickChacon
Copy link
Member Author

Should I do it similar to the existing test with "geojson"?

That would be great, but feel free to add other tests you have in mind too.

Ok. Should it be better to make the writing test inside the formats testset, so we can take advantage of the already loaded data?

@juliohm
Copy link
Member

juliohm commented May 4, 2023

Makes sense to move the writing tests to inside the other test sets. Maybe we can remove the outer "load" test set then?

@ErickChacon
Copy link
Member Author

Makes sense to move the writing tests to inside the other test sets. Maybe we can remove the outer "load" test set then?

Yes, that is what I have in mind. I will do that.

@ErickChacon
Copy link
Member Author

I've updated the test/Project.toml in GADM.jl to see if the issue was coming from there, and learned that ArchGDAL.jl is not even building there in GitHub Actions: JuliaGeo/GADM.jl#49

It builds in Julia 1.6 - ubuntu, but there is still an HTTP problem.

get: Error During Test at /home/runner/work/GADM.jl/GADM.jl/test/GADM.jl:34
  Got exception outside of a @test
  HTTP.Exceptions.RequestError(HTTP.Messages.Request:
  """
  GET /data/gadm3.6/gpkg/gadm36_SUR_gpkg.zip HTTP/1.1
  Host: biogeo.ucdavis.edu
  Accept: */*
  User-Agent: HTTP.jl/1.6.7
  Content-Length: 0

@ErickChacon
Copy link
Member Author

ErickChacon commented May 4, 2023

I added tests for writing to .shp and .geojson for points, lines, polygons and multipolygons. I consider this PR completed. All tests are passing in my linux machine.

test/runtests.jl Outdated
Comment on lines 204 to 205
writedir = joinpath(tempdir(), "geotables")
mkdir(writedir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should write to the datadir that is already defined. Can we avoid creating a new directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@codecov-commenter
Copy link

Codecov Report

Merging #15 (37fa290) into master (cea71c8) will decrease coverage by 1.18%.
The diff coverage is 86.31%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master      #15      +/-   ##
==========================================
- Coverage   88.57%   87.39%   -1.18%     
==========================================
  Files           3        3              
  Lines          70      119      +49     
==========================================
+ Hits           62      104      +42     
- Misses          8       15       +7     
Impacted Files Coverage Δ
src/conversion.jl 83.87% <83.87%> (+12.44%) ⬆️
src/geotable.jl 88.57% <86.66%> (-5.37%) ⬇️
src/GeoTables.jl 95.45% <94.44%> (-4.55%) ⬇️

@juliohm juliohm merged commit 02e6d88 into JuliaEarth:master May 4, 2023
@juliohm
Copy link
Member

juliohm commented May 4, 2023

Thank you @ErickChacon! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants