Code Monkey home page Code Monkey logo

Comments (5)

calvinmetcalf avatar calvinmetcalf commented on August 27, 2024

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 [email protected] 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
.

from esri2open.

AlexArcPy avatar AlexArcPy commented on August 27, 2024

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.

from esri2open.

calvinmetcalf avatar calvinmetcalf commented on August 27, 2024

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.

from esri2open.

AlexArcPy avatar AlexArcPy commented on August 27, 2024

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

from esri2open.

calvinmetcalf avatar calvinmetcalf commented on August 27, 2024

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.

from esri2open.

Related Issues (16)

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.