SpatioTemporal / STAREPandas

STAREpandas adds SpatioTemporal Adaptive Resolution Encoding (STARE) support to pandas DataFrames. https://starepandas.readthedocs.io/en/latest/
MIT License
4 stars 1 forks source link

use_convex and force_ccw clarification #154

Open NiklasPhabian opened 11 months ago

NiklasPhabian commented 11 months ago

How does use_convex and force_ccw work?

Let's

import shapely.geometry
import geopandas
import starepandas

lons = [+179.000, -180.000, -179.000, -179.000, -179.000, -180.000, +179.000, +179.000]
lats = [ +44.000, +44.000, +44.000, +45.000, +46.000, +46.000, +46.000, +45.000]
q_lev = 11

verts = list(zip(lons, lats))
poly = shapely.geometry.Polygon(verts)
gdf = geopandas.GeoDataFrame(crs='4326', geometry=[poly])

sdf1 = starepandas.STAREDataFrame(gdf, add_sids=True, level=q_lev)
sids1 = sdf1.sids

sdf2 = starepandas.STAREDataFrame(gdf)
sids2 = b_sdf.make_sids(level=q_lev, convex=False, force_ccw=False)

Now let's check the number of sids

sids1.iloc[0].shape

(352,)

sids2.iloc[0].shape

(628,)

Why do these yield different results?

The STAREDataFrame constructor does not give us the full ability to configure the creation of the sids. Default values are used instead. I.e. convex=False and force_ccw=True.

The polygon we defined is clockwise. The STAREDataFrame constructor by default reverses the order to make it ccw making the ring the outer bound. in our make_sids call, we do not force ccw, making the ring the inner bound. I.e. the SIDs correspond to trixels covering everything on earth except the polygon.

poly.exterior.is_ccw

False