ropensci-archive / wicket

:no_entry: ARCHIVED :no_entry: Utilities to Handle WKT Spatial Data
Other
9 stars 1 forks source link

Convert wkt to bounding boxes, and vice versa #5

Closed Ironholds closed 7 years ago

Ironholds commented 7 years ago

There should be two functions, bounding_wkt and wkt_bounding:

bounding_wkt(min_x = NULL, min_y = NULL, max_x = NULL, max_y = NULL, box = NULL) wkt_bounding(wkt, as_matrix = FALSE)

bounding_wkt should:

  1. Accept either four vectors of X and Y values, or a list of length-4 vectors, or a sp Polygon object;
  2. Convert all into WKT POLYGON objects representing a bounding box of the values
  3. Return that as a character vector

wkt_bounding should:

  1. Accept a vector of WKT POLYGON objects
  2. Convert those into either a data.frame or matrix of values
sckott commented 7 years ago

looks good.

wrt supporting converting other WKT types to bbox's: polygon and multipolygon for sure. usually that's all the web APIs we interact with support. but in theory could calculate bbox for any object, even a point even though that's a bit silly. i imagine others would want any WKT supported. i guess if easy enough to do, but if hard, then just polygon and multipolygon

another issue is polygon/multipolygon inside a featurecollection or geometrycollection - but at least for our purposes, we won't be dealing with that

Ironholds commented 7 years ago

Well, GeometryCollection is a type the contract requests this supports, right?

sckott commented 7 years ago

looks like we included GeometryCollection as one one of the types to lint (see bullet 3)

for wkt_bounding: i think should include Point, Multipoint, LineString, MultiLineString, Polygon, MultiPolygon, and GeometryCollection

Ironholds commented 7 years ago

Sounds good!

Ironholds commented 7 years ago

Wait, actually - isn't GeometryCollection potentially impossible? Insofar as a GC object can refer to multiple actual polygons. What to do in that case would be...unclear.

sckott commented 7 years ago

What to do in that case would be...unclear

what to do in what case? what do you mean by impossible?

Ironholds commented 7 years ago

Bounding boxes for GeometryCollection objects - IOW, how (and why) one would go about calculating the envelope of a potentially infinite set of discrete objects, stored as a geometrycollection

Ironholds commented 7 years ago

Bounding boxes for GeometryCollection objects - IOW, how (and why) one would go about calculating the envelope of a potentially infinite set of discrete objects, stored as a geometrycollection

sckott commented 7 years ago

Okay, let's drop GC's for now

Ironholds commented 7 years ago

Alright, first version is pretty much done (tm). It currently takes just under a second to turn 100,000 WKT objects into bounding boxes - that acceptable?

sckott commented 7 years ago

Yes, bueno 👌

Ironholds commented 7 years ago

Cool!

Ironholds commented 7 years ago

And WKT polygon generation takes...0.3 seconds from vectors, 0.4 from a list. Excellent. :D

sckott commented 7 years ago

noooiice

Ironholds commented 7 years ago

On the SP-to-bounding - presumably we can handle this indirectly by supporting (in sequence) SP-to-WKT and WKT-to-bounding conversion, da?

sckott commented 7 years ago

sounds good.

Ironholds commented 7 years ago

Okay, these functions (as wkt_bounding and bounding_wkt) are officially Ready For Alpha Testing (tm)

sckott commented 7 years ago

All looks good, tested out a bit, nothing I can see that needs changing

Ironholds commented 7 years ago

Sweet!