-
Notifications
You must be signed in to change notification settings - Fork 26
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
Table to IFeatureLayer #243
Open
mathieu17g
wants to merge
45
commits into
yeesian:master
Choose a base branch
from
mathieu17g:IFeatureLayer_from_table
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
fd7eeec
1st draft of an IFeatureLayer constructor from table
mathieu17g 163e9b8
Fixed IFeatureLayer(table) for tables not supporting view on row (e.g…
mathieu17g 9e0e900
Test table to `IFeatureLayer` conversion with a`missing`, mixed geome…
mathieu17g 91e3a10
Fixed handling of type Any in a column and modified error messages
mathieu17g a79ec71
Fixed conversion to OGRFieldType error handing
mathieu17g 843155d
JuliaFormatter formating
mathieu17g d8849e4
Handling of `Tables.schema` returning `nothing` or `Schema{names, no…
mathieu17g a5090a0
Added basic conversion to layer documentation in "Tables interface" s…
mathieu17g 848fe0e
Completed doc on conversion to layer with an example of writing to a …
mathieu17g 0bd76de
Added in doc an example of writing to the GML more capable driver
mathieu17g 2045d55
Fixed a typo in table docs
mathieu17g a6277af
Added docstring with example to IFeatureLayer(table)
mathieu17g 5035a0e
Formatted with JuliaFormatter
mathieu17g 541ff9b
Fixed a typo on name option for IFeatureLayer(table)
mathieu17g 1b6ab33
Added `nothing` values handling (cf. PR #238):
mathieu17g 7fa434c
`_fromtable` function code readability enhancements:
mathieu17g 8f8b1bd
Fixed a typo in `_fromtable` column types conversion error message
mathieu17g 0e12703
Corrections following @yeesian review
mathieu17g 6454e09
Fixed arg type in `ctv_toWKT` signature ("Table to layer conversion" …
mathieu17g 8f07154
Added GeoInterface geometries handling to table to layer conversion
mathieu17g a4bd378
Fixed typo in GeoInterface to IGeometry conversion and added tests on it
mathieu17g 7166097
Added tests on GeoInterface geometries types to `OGRwkbGeometryType`
mathieu17g 33c3a76
Formatting and cleaning
mathieu17g 0b1b9d9
Added WKT and WKB parsing options in table to layer conversion
mathieu17g f8da022
Enhance test coverage by pruning handling of `Vector{String}` convers…
mathieu17g c0e4da6
Corrected a typo in `_fromtable`
mathieu17g 77d561d
Extended test coverage by testing individually GeoInterface, WKT, WKB…
mathieu17g a33bc88
Merge branch 'master' into IFeatureLayer_from_table
mathieu17g b08919b
Folliowing @visr and @yeesian remarks:
mathieu17g d41cbc2
Fixed test_tables.jl to use `layer_name` kwarg instead of `name` to c…
mathieu17g 1ff0196
Added geometry column specification kwarg `geom_cols`, without any te…
mathieu17g 125a076
Added `fieldtypes` kwarg option to table to layer conversion, without…
mathieu17g 9e90dc1
Added tests on `geomcols` kwarg and corrected issues revealed while a…
mathieu17g f57a867
A few issue fixes while adding test to `fieldtypes` kwarg option.
mathieu17g 8911988
Added test on `fieldtypes` kwarg and fixed issues raised by those tests
mathieu17g fbb4618
Added error message test in `@test_throws` tests for `fieldtypes` and…
mathieu17g 1d39170
Merge branch 'master' into IFeatureLayer_from_table
mathieu17g 5cd1f16
Modified conversion from `GeoInterface.AbstracGeometry` to `IGeometry`
mathieu17g d08a47c
Exclude columns in `fieldtypes` from WKT/WKB parsing in `_infergeomet…
mathieu17g ad14efd
Typo in the previous commit `spfieldtypes` intead of `fieldtypes`
mathieu17g 0c61b85
Deleted 2 comments in `_fromtable(sch::Tables.Schema{names,types}, ..…
mathieu17g 60df39e
Dropped `fieldtypes` kwarg in src and tests
mathieu17g a197973
Merge branch 'master' into IFeatureLayer_from_table
mathieu17g 6ae870c
Refixed `ogrerr` macro
mathieu17g e8560e4
Dropped `geomcols` kwarg and WKT/WKB parsing in src/ and test/
mathieu17g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,71 @@ | ||
# Tabular Interface | ||
|
||
```@setup tables | ||
using ArchGDAL, DataFrames | ||
using ArchGDAL; AG = ArchGDAL | ||
using DataFrames | ||
``` | ||
|
||
ArchGDAL now brings in greater flexibilty in terms of vector data handling via the | ||
[Tables.jl](https://github.com/JuliaData/Tables.jl) API. In general, tables are modelled based on feature layers and support multiple geometries per layer. Namely, the layer(s) of a dataset can be converted to DataFrame(s) to perform miscellaneous spatial operations. | ||
|
||
## Conversion to table | ||
|
||
Here is a quick example based on the | ||
[`data/point.geojson`](https://github.com/yeesian/ArchGDALDatasets/blob/307f8f0e584a39a050c042849004e6a2bd674f99/data/point.geojson) | ||
dataset: | ||
|
||
```@example tables | ||
dataset = ArchGDAL.read("data/point.geojson") | ||
|
||
DataFrames.DataFrame(ArchGDAL.getlayer(dataset, 0)) | ||
```@repl tables | ||
ds = AG.read("data/point.geojson") | ||
DataFrame(AG.getlayer(ds, 0)) | ||
``` | ||
|
||
To illustrate multiple geometries, here is a second example based on the | ||
[`data/multi_geom.csv`](https://github.com/yeesian/ArchGDALDatasets/blob/master/data/multi_geom.csv) | ||
dataset: | ||
|
||
```@example tables | ||
dataset1 = ArchGDAL.read("data/multi_geom.csv", options = ["GEOM_POSSIBLE_NAMES=point,linestring", "KEEP_GEOM_COLUMNS=NO"]) | ||
```@repl tables | ||
ds = AG.read("data/multi_geom.csv", options = ["GEOM_POSSIBLE_NAMES=point,linestring", "KEEP_GEOM_COLUMNS=NO"]) | ||
DataFrame(AG.getlayer(ds, 0)) | ||
``` | ||
## Conversion to layer | ||
A table-like source implementing Tables.jl interface can be converted to a layer, provided that: | ||
- Source contains at least one geometry column | ||
- Geometry columns are recognized by their element type being a subtype of `Union{IGeometry, Nothing, Missing}` | ||
- Non geometry columns must contain types handled by GDAL/OGR (e.g. not `Int128` nor composite type) | ||
|
||
**Note**: As geometries and fields are stored separately in GDAL features, the backward conversion of the layer won't have the same column ordering. Geometry columns will be the first columns. | ||
|
||
DataFrames.DataFrame(ArchGDAL.getlayer(dataset1, 0)) | ||
```@repl tables | ||
df = DataFrame([ | ||
:point => [AG.createpoint(30, 10), missing], | ||
:mixedgeom => [AG.createpoint(5, 10), AG.createlinestring([(30.0, 10.0), (10.0, 30.0)])], | ||
:id => ["5.1", "5.2"], | ||
:zoom => [1.0, 2], | ||
:location => [missing, "New Delhi"], | ||
]) | ||
layer = AG.IFeatureLayer(df) | ||
``` | ||
|
||
The layer, converted from a source implementing the Tables.jl interface, will be in a [memory](https://gdal.org/drivers/vector/memory.html) dataset. | ||
Hence you can: | ||
- Add other layers to it | ||
- Copy it to a dataset with another driver | ||
- Write it to a file | ||
### Example of writing with ESRI Shapefile driver | ||
```@repl tables | ||
ds = AG.write(layer.ownedby, "test.shp", driver=AG.getdriver("ESRI Shapefile")) | ||
DataFrame(AG.getlayer(AG.read("test.shp"), 0)) | ||
rm.(["test.shp", "test.shx", "test.dbf"]) # hide | ||
``` | ||
!!! warning | ||
As OGR ESRI Shapefile driver [does not support multi geometries](https://gdal.org/development/rfc/rfc41_multiple_geometry_fields.html#drivers), the second geometry has been dropped | ||
!!! warning | ||
As OGR ESRI Shapefile driver does not support nullable fields, the `missing` location has been replaced by `""` | ||
### Example of writing with GML driver | ||
Using the GML 3.2.1 more capable driver/format, you can write more information to the file | ||
```@repl tables | ||
ds = AG.write(layer.ownedby, "test.gml", driver=AG.getdriver("GML"), options=["FORMAT=GML3.2"]) | ||
DataFrame(AG.getlayer(AG.read("test.gml", options=["EXPOSE_GML_ID=NO"]), 0)) | ||
rm.(["test.gml", "test.xsd"]) # hide | ||
``` | ||
**Note:** [OGR GML driver](https://gdal.org/drivers/vector/gml.html#open-options) option **EXPOSE\_GML\_ID=NO** avoids to read the `gml_id` field, mandatory in GML 3.x format and automatically created by the OGR GML driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be named as
_show
or something, or does it need to have theBase.
prefix?