Giter Club home page Giter Club logo

gatsby-source-geo's People

Contributors

andrewl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gatsby-source-geo's Issues

GraphQL Omits Coordinates with Conflicting Types

Interesting issue I've run into here that seems to be a conflict when you're using data from several different shapefiles.

A little background -- I'm using data from two different .shp files -- one of these files defines a series of polygons (it is showing census tracts) and another defines a series of points.

The coordinates of the polygons are represented in GeoJSON as an array of length 2 arrays like so:

"coordinates": [[700, -600], [701, -601], [702, -602]] 

The points, on the other hand, are represented by a single array of length 2, like so:

"coordinates": [700, -600]

GraphQL/Gatsby doesn't like this, as it treats these as conflicting datatypes with the following error message:

warn There are conflicting field types in your data.

If you have explicitly defined a type for those fields, you can safely ignore this warning message.
Otherwise, Gatsby will omit those fields from the GraphQL schema.

If you know all field types in advance, the best strategy is to explicitly define them with the `createTypes` action, and skip inference with the `@dontInfer` directive.
See https://www.gatsbyjs.org/docs/actions/#createTypes
geoFeature.geometry.coordinates:
 - type: [array]
   value: [ ..., [ ..., [ ..., -71.160393, ... ], ... ], ... ]
 - type: [number]
   value: [ ..., 236007.5383913815, ... ]

The coordinates field is then omitted from the results, to my dismay.

I've got the repository forked to try and fix this -- this seems to be within GeoJSON specification (see: https://geojson.org/). My approach right now is to simply split each datasource into separate nodes (since they all end up together under allGeoFeature) but this might prove problematic for shapefiles that define both polygons and points.

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.