question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polygon Layer documentation - coordinate specification

See original GitHub issue

Background

Polygon layer coordinate specification

The documentation for polygon layer specifies the following data format

/**
   * Data format:
   * [
   *   {
   *     // Simple polygon (array of coords)
   *     contour: [[-122.4, 37.7], [-122.4, 37.8], [-122.5, 37.8], [-122.5, 37.7], [-122.4, 37.7]],
   *     zipcode: 94107,
   *     population: 26599,
   *     area: 6.11
   *   },
   *   {
   *     // Complex polygon with holes (array of coords)
   *     contour: [
   *       [[-122.4, 37.7], [-122.4, 37.8], [-122.5, 37.8], [-122.5, 37.7], [-122.4, 37.7]],
   *       [[-122.45, 37.73], [-122.47, 37.76], [-122.47, 37.71], [-122.45, 37.73]]
   *     ],
   *     zipcode: 94107,
   *     population: 26599,
   *     area: 6.11
   *   },
   *   ...
   * ]
   */

I’ve just generated an example which has coordinates in the form of

{
  "geometry":{
    "type":"Polygon",
    "coordinates":[
      [
        [-162.96333331843185, 23.963333318432139,-94860.0,1.0],
        [-162.89693422519478, 23.963333318432139,-95135.0,1.0]
        ... etc
     ]
   ]
}
}

Where the elevation is specified as the 3rd value in each coordinate array (as per GeoJSON).

Which gives

quadmesh

Should the documentation reflect that you can specify the elevation in the coordinate array, as well as in the getElevation prop?

And is this a valid way to supply the elevation?


Related issue from my mapdeck library

Update

The same works for pathLayer too, where you can specify the elevation in the coordinates [ ] array


To Do List

  • Add label and assign to milestone
  • Coding
  • Doc update
  • Whats new update
  • Test

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdsumnercommented, Nov 27, 2018

No problem!

1reaction
SymbolixAUcommented, Nov 26, 2018

@mdsumner I had the same question - hopefully this helps

Setting up some data (in R)

poly1<- matrix(c(0,0,0,0,1,1000,1,1,50000,1,0,25000,0,0,0), ncol = 3, byrow = T)
poly2<- matrix(c(0,0,0,0,-1,1000,-1,-1,50000,-1,0,25000,0,0,0), ncol = 3, byrow = T)

poly1 <- sf::st_sfc( sf::st_polygon( x = list( poly1 ) ) )
poly2 <- sf::st_sfc( sf::st_polygon( x = list( poly2 ) ) )

poly1 <- sf::st_sf( geometry = poly1 )
poly2 <- sf::st_sf( geometry = poly2 )

sf <- rbind( poly1, poly2 )
sf$id <- 1:2

The polygons have a Z attribute. I’m making two plots, one using the extrusion, and one without

Non-extruded

Just using the Z attribute on the data

mapdeck() %>%
	add_polygon(
		data = sf
		, fill_colour = "id"
	)

polygon_non_extruded

Extruded

uses getElevation to extrude the polygon from the map

mapdeck() %>%
	add_polygon(
		data = sf
		, elevation = 100000
		, fill_colour = "id"
	)

polygon_extruded

So the Z is applied for each vertex. The extrusion is applied to the whole polygon, while respecting the initial Z elevation (as both the base and top surfaces are tilted)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polygon Layer documentation - coordinate specification #2435
Background Polygon layer coordinate specification The documentation for polygon layer specifies the following data format /** * Data format: ...
Read more >
Creating a polygon grid with specified coordinates—ArcMap
With the Create Polygon Grid Wizard, you can define the size of the polygon grid using coordinates you specify. The size of the...
Read more >
PolygonLayer - deck.gl
Compatible with the GeoJSON Polygon specification. A flat array or TypedArray of coordinates, in the shape of [x0, y0, z0, x1, y1, z1,...
Read more >
GeoJSON specification
GeoJSON uses a geographic coordinate reference system, World Geodetic ... This document supersedes the original GeoJSON format specification [GJ2008].
Read more >
polygon | Help - Mapbox docs
A polygon is a geospatial feature defined by connected pairs of latitude and longitude coordinates forming an area with at least three sides....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found