-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
How does use_convex and force_ccw work?
Let's
- create a single polygon from a single ring and then
- create a gdf with this single polygon
- and then create a sdf from the gdf
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.
convex=Falsemeans we are computing the SIDs for the actual exterior ring, not for it's convex hullforce_ccw=Trueensures that the exterior ring is counterclockwise and the interior rings clockwise. Unfortunately, this is a bit of a clusterfuck. We use the OGC definition. I.e. we need exterior rings to be CCW.
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_ccwFalse
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation