Skip to content

abiraihan/geoshapes

Repository files navigation

📚 geoshapes Library

PyPI version Build Status Project Status: Active – The project has reached a stable, usable state and is being actively developed. FOSSA Status License: MIT DOI PyPI Downloads

📝 Experimental design for geospatial analytics. To split Polygon geometry into different shape that required to create experimental plot / trial design. It creates experimental plot design to summerize data to geospatially enabled space for next-step mathematical modelling.

Run example code on mybinder.org

🖊️ You can run geoshapes example code on Binder without installing any library in your python environment. It doesn't requie any dependency to install and you can run all those example from the mybinder.org

📚 Required Library ▶️ Required python library prior to install geoshapes

Install geoshapes

pip install geoshapes

Module Summery:

✏️ Example

🌏 geoshapes.splitShape.splitCircle

▶️ Split a circle geometry with defined indentifier as a treatment plot

import string, shapely, geoshapes, geopandas
pointLocation = shapely.geometry.Point(0,0)
polygonList = geoshapes.splitShape.splitCircle(
    geoms = pointLocation,
    circleRadius = 500,
    incrementDegree = 45,
    clipInterior = True,
    innerWidth = 100,
    getGeom = 'Both'
    )
gdf = geopandas.GeoDataFrame(
    geometry = polygonList,
    crs = 'EPSG:3857'
    )
gdf['ids'] = range(len(gdf))
gdf['Group']= gdf.apply(
    lambda row : string.ascii_uppercase[int(row.ids)],
    axis = 1)
ax = gdf.plot(figsize=(15, 10),
alpha=0.0, edgecolor='k')
gdf.plot(column='Group',
         ax=ax, linewidth=9,
         cmap='tab20');
gdf.apply(lambda x: ax.annotate(
    text=f"Group : {x.Group}{x.ids}",
    xy=x.geometry.centroid.coords[0],
    weight='bold', ha='center',
    va='center', size=10),axis=1
    )

🗺️ splitsCircle

Split CIrcle


🌏 geoshapes.splitShape.splitLatin

▶️ Split a square geometry with defined indentifier as a latin square treatment plot

import string, shapely, geoshapes, geopandas
point = shapely.geometry.Point(0,0)
latinShpae = geoshapes.splitShape.splitLatin(point, 25)
featureGeoms = geopandas.GeoDataFrame(
    geometry = latinShpae,
    crs = 'EPSG:4326'
    )
featureGeoms['ids'] = range(len(featureGeoms))
featureGeoms['Group']= featureGeoms.apply(
    lambda row : string.ascii_uppercase[int(row.ids)],
    axis = 1
    )
ax = featureGeoms.plot(
    figsize=(15, 10),
    alpha=0.4, edgecolor='k')
featureGeoms.plot(
    column='Group', ax=ax,
    linewidth=9, cmap='tab20'
    );
featureGeoms.apply(
    lambda x: ax.annotate(
        text=f"{x.Group}",
        xy=x.geometry.centroid.coords[0],
        ha='center',
        va='center',
        size=20),axis=1
    )

🗺️ splitLatin

Latin Square


License

FOSSA Status