.from_features does not retrieve feature 'id'
See original GitHub issueProblem
geopandas: 0.6.1
The GeoJSON spec says a feature object can include an id property. Ref Section 3.3.3:
If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name “id”.
However, when loading data into a GeoDataFrame
using from_features
, this data is not retrieved.
Example:
df = gpd.GeoDataFrame.from_features(
{
"type": "FeatureCollection",
"features": [
{
"id": "ST0",
"type": "Feature",
"properties": {
"atco_code": "300000492FZ",
"bearing": 8,
"feature_name": "Demand Responsive Area",
"type": "BCT",
},
"geometry": {
"type": "Point",
"coordinates": (-1.1372773238238423, 52.346655194010665),
},
},
{
"id": "ST1",
"type": "Feature",
"properties": {
"atco_code": "0600CR19133",
"bearing": 2,
"feature_name": "Station View (E-bound)",
"type": "BCT",
},
"geometry": {
"type": "Point",
"coordinates": (-2.518177475249135, 53.063122731640604),
},
},
],
}
)
Output:
Out[8]:
geometry atco_code bearing feature_name type
0 POINT (-1.13728 52.34666) 300000492FZ 8 Demand Responsive Area BCT
1 POINT (-2.51818 53.06312) 0600CR19133 2 Station View (E-bound) BCT
Expected
The id property is returned as a column in the GeoDataFrame
:
Out[10]:
geometry atco_code bearing feature_name type id
0 POINT (-1.13728 52.34666) 300000492FZ 8 Demand Responsive Area BCT ST0
1 POINT (-2.51818 53.06312) 0600CR19133 2 Station View (E-bound) BCT ST1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Unable to find references to missing features during upgrade
My question is: how do I clean this up? "Select" from Features table based on these GUIDs does not return anything since these...
Read more >OpenLayers can't get feature by key, undefined error
I stored every info I need under info key. I tried to get data in console and I can see that a point...
Read more >How to get feature id for particular ... - GIS Stack Exchange
You just need to call for the feature id, the same way you would for the feature geometry: changed_polygon_id = ev.feature.id;.
Read more >How to find a Feature ID in SharePoint using IE Developer ...
Feature Name Feature Definition Id Scope
DocumentRoutingResources 0c8a9a47‑22a9‑4798‑82f1‑00e62a96006e Site
PublishingPrerequisites a392da98‑270b‑4e85‑9769‑04c0fde267aa Site
HelpCollectionRemoveDefault 232b3f94‑9d6e‑4ed6‑8d55‑04d5a44ac449 Site
Read more >How to group features based on ID in gff - Biostars
So what I want to do is remove IDs from features with the same IDs and create a parent feature that appears before...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @jorisvandenbossche No problem at all!
Ah I see, that is a potential issue! I would be happy to help and contribute a pull request if a decision could be made on how to proceed.
How about having an additional function parameter to extract the ID? E.g.
This wouldn’t help making it work with all file formats but could provide an opt-in, best-try attempt.
I too would like the ‘id’ to get read by
.from_features
.