Package: nzgeom
NZ geometriesProvides geospatial geometries describing New Zealand coastlines and regional administrative boundaries.Installationpip install nzgeomorconda install -c conda-forge nzgeom`Usage Examples>>>importnzgeom.coastlines>>>c=nzgeom.coastlines.get_NZ_coastlines()>>>cnamemacronated...name_asciigeometry0NoneN...NoneMULTIPOLYGON(((175.76343-36.43109,175.76327...1NoneN...NoneMULTIPOLYGON(((175.76337-36.43096,175.76312...2NoneN...NoneMULTIPOLYGON(((168.14925-47.11982,168.14868...3NoneN...NoneMULTIPOLYGON(((166.90386-46.58083,166.90376...4LionRockN...LionRockMULTIPOLYGON(((175.75020-36.77198,175.74985.....................9134Tāhuahua-Paopao-KaroroIslandY...Tahuahua-Paopao-KaroroIslandMULTIPOLYGON(((173.28982-34.90622,173.29034...9135WakatehāuaIslandY...WakatehauaIslandMULTIPOLYGON(((172.89280-34.68681,172.89304...9136Ōhau/WestIslandY...Ohau/WestIslandMULTIPOLYGON(((172.03345-34.18387,172.03354...9137Manawatāwhi/GreatIslandY...Manawatawhi/GreatIslandMULTIPOLYGON(((172.14683-34.14436,172.14729...9138NorthIslandorTeIka-a-MāuiY...NorthIslandorTeIka-a-MauiMULTIPOLYGON(((175.13516-41.37745,175.13507...If matplotlib is available, it's easy to plot the coastline geodataframe (or add the coastlines to an existing plot):>>>importmatplotlib.pyplotasplt>>>ax=c.plot>>>ax.set_xlim([165,180])>>>plt.show()For the council region boundaries:>>>importnzgeom.regions>>>r=nzgeom.regions.NZRegions()>>>r.list_regions()NorthlandRegionAucklandRegionWaikatoRegionBayofPlentyRegionGisborneRegionHawke's Bay RegionTaranakiRegionManawatu-WanganuiRegionWellingtonRegionWestCoastRegionCanterburyRegionOtagoRegionSouthlandRegionTasmanRegionNelsonRegionMarlboroughRegionAreaOutsideRegion>>>r.get_region_geodataframe("Auckland Region")REGC2018_V1_00REGC2018_V1_00_NAMELAND_AREA_SQ_KMAREA_SQ_KMShape_Lengthgeometry102AucklandRegion4941.57255716156.610062659677.328124MULTIPOLYGON(((1788533.2656047342.800,17891...Mask a grid's coordinates to land areas within the Wellington Region:importnumpyasnpimportmatplotlib.pyplotaspltimportgeopandasasgpdfromshapely.geometryimportPointimportnzgeom.coastlinesimportnzgeom.regionsLATLON="EPSG:4326"coast=nzgeom.coastlines.get_NZ_coastlines().to_crs(LATLON)nzreg=nzgeom.regions.NZRegions()wellington_region=nzreg.get_region_geodataframe("Wellington Region").to_crs(LATLON)# make a 0.1 by 0.1 degree grid, put it in a geopandas.GeoDataFramegrid_lons,grid_lats=np.meshgrid(np.arange(174.4,176.5,0.1),np.arange(-41.8,-40.4,0.1))dummy_grid=gpd.GeoDataFrame(geometry=[Point(lon,lat)forlon,latinzip(grid_lons.flatten(),grid_lats.flatten())],crs=LATLON,)# mask out points outside Wellington Regiondummy_grid_wellington_landonly=gpd.clip(dummy_grid,wellington_region)# mask out water pointsdummy_grid_wellington_landonly=gpd.clip(dummy_grid_wellington_landonly,coast)# draw the coastlines, Wellington Region, the full grid, and the masked grid.fig,ax=plt.subplots()coast.plot(ax=ax,color="lightgray",label="New Zealand")wellington_region.plot(ax=ax,color="None",label="Wellington Region")dummy_grid.plot(ax=ax,marker="x",color="#1b9e77",alpha=0.7,label="full grid")dummy_grid_wellington_landonly.plot(ax=ax,marker="+",color="#d95f02",alpha=0.7,label="Wellington & land")ax.set_xlim([172,179])ax.set_ylim([-43.0,-39.5])ax.legend()plt.show()CreditsTheRegional Council boundary dataare provided byStats NZ Tatauranga Aotearoaunder the terms of theCreative Commons Attribution 4.0 International.TheNZ coastlines dataare provided byToitū Te Whenua Land Information New Zealandunder the terms of theCreative Commons Attribution 4.0 International.