项目作者: andrewl

项目描述 :
Geospatial Source Plugin for gatsby
高级语言: JavaScript
项目地址: git://github.com/andrewl/gatsby-source-geo.git
创建时间: 2018-12-22T15:14:50Z
项目社区:https://github.com/andrewl/gatsby-source-geo

开源协议:MIT License

下载


gatsby-source-geo

Plugin for creating nodes from geospatial data sources. Each layer is exposed as a GeoLayer node, each geographic feature a GeoFeature - each of these nodes can be published, or referenced or whatever in graphql.

Uses the node-gdal module for accessing underlying geospatial data sources.

Install

You’ll need to install both this module and the gdal module.

npm i gatsby-source-geo gdal

How to use

  1. // In your gatsby-config.js
  2. module.exports = {
  3. plugins: [
  4. {
  5. resolve: `gatsby-source-geo`,
  6. options: {
  7. path: `${__dirname}/data/myfile.geojson`,
  8. // optional per layer filters
  9. layers: [
  10. {
  11. //name of the layer to filter
  12. name: `some_layer`,
  13. //partial WHERE query to filter by attribute
  14. attribute_filter: `some_field = 'somevalue'`,
  15. }
  16. ],
  17. },
  18. },
  19. ],
  20. }

Options

path - it’s just the location of the geospatial data file (eg /tmp/myfile.geojson)

How to query

You can query GeoLayer nodes from geospatial data in the following way:

  1. {
  2. allGeoLayer {
  3. edges {
  4. node {
  5. id
  6. name
  7. srs_wkt
  8. }
  9. }
  10. }
  11. }

You can query GeoFeature nodes from geospatial data in the following way:

  1. {
  2. allGeoFeature {
  3. edges {
  4. node {
  5. id
  6. geometry {
  7. type
  8. coordinates
  9. }
  10. featureFields {
  11. my_first_field
  12. my_second_field
  13. etc
  14. }
  15. }
  16. }
  17. }
  18. }

geometry will contain the features’ geometry in GeoJSON format, and the contents of featureFields will vary depending upon the schema definition of the data that you’re querying.