Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

It would be great to be able to specify the id field for GeoJSON #32

Open
AlexArcPy opened this issue Aug 1, 2016 · 5 comments
Open

Comments

@AlexArcPy
Copy link

Currently, the OID field of a feature class is used when converting the feature class to a GeoJSON. However, most often this unique ID doesn't have any meaning and it would be great to choose the field that will become the id for features in GeoJSON. When doing plotting and map bindings with such Python libraries as folium and vincent, having a meaningful id is required.

I solve this for my needs by editing the line
https://github.com/project-open-data/esri2open/blob/master/Install/esri2open/parseRow.py#L16
with the field name I want to have as id in the output GeoJSON.

replaced
self.oid=getOID(self.fields)

with
self.oid='FIELD_NAME'

@calvinmetcalf
Copy link
Contributor

it's pretty easy to change the id field later and from a quick paruse of
the folium docs they just use 'feature.id' in there examples, there doesn't
seem to be any reason you cant replace that with
'feature.properties.FIELD_NAME'

On Mon, Aug 1, 2016 at 10:47 AM AlexArcPy notifications@github.com wrote:

Currently, the OID field of a feature class is used when converting the
feature class to a GeoJSON. However, most often this unique ID doesn't have
any meaning and it would be great to choose the field that will become the
id for features in GeoJSON. When doing plotting and map bindings with such
Python libraries as folium and vincent, having a meaningful id is
required.

I solve this for my needs by editing the line

https://github.com/project-open-data/esri2open/blob/master/Install/esri2open/parseRow.py#L16
with the field name I want to have as id in the output GeoJSON.

replaced
self.oid=getOID(self.fields)

with
self.oid='FIELD_NAME'


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#32, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ABE4n2NzB6FLmetv1wzsRVWnirNUH9Ffks5qbgbmgaJpZM4JZqSG
.

@AlexArcPy
Copy link
Author

AlexArcPy commented Aug 1, 2016

Well, if you have as field name OID, then you get as id values from the ObjectID, which are integers. If I wanted to have state names, for instance, I had to pull the state names from another field, not the ObjectID field. Doable in Python parsing the GeoJSON, but much easier to do it right from the beginning.

I've tried feature.properties.FIELD_NAME, good point. Didn't work for me. In the docs, they say that it always should be feature.id, so you do need to have id in GeoJSON.

@calvinmetcalf
Copy link
Contributor

its actually a field of type oid not name oid that it looks for, and where did you see that in the docs? I might be looking in the wrong place.

@AlexArcPy
Copy link
Author

AlexArcPy commented Aug 1, 2016

I know that it is looking of ObjectID field type :) whatever, it is pulling those 1,2,3 etc into id which are completely useless in GeoJSON. You would want to have some something meaningfull.

My bad, it does say that it's possible to use the feature.properties. Good catch, thanks! By the way, got it working with feature.properties.%field_name%. Cool.

Anyway, as an improvement, it would be great to be able to pull values from another field into id. :P

@calvinmetcalf
Copy link
Contributor

feel free to open a pull, though bear in mind ids can only be strings or numbers so not every field can be the id. Also since id's are 100% optional if you have software relying on them, you may want to open issues with those libraries.

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

No branches or pull requests

2 participants