diff --git a/nes/nc_projections/points_nes.py b/nes/nc_projections/points_nes.py index 8d5ccff15b5b5ff5ce645ea58e8dbb90eac5cadc..1847fdebb3df04c0c45ce7699a91b576237521b2 100644 --- a/nes/nc_projections/points_nes.py +++ b/nes/nc_projections/points_nes.py @@ -3,7 +3,9 @@ import sys import warnings import numpy as np +import pandas as pd from copy import deepcopy +import geopandas as gpd from netCDF4 import date2num, stringtochar from numpy.ma.core import MaskError from .default_nes import Nes @@ -645,4 +647,11 @@ class PointsNes(Nes): Create spatial geodataframe (shapefile). """ - raise NotImplementedError("Shapefile format cannot be written with point data.") + # Create dataframe cointaining all points + geometry = gpd.points_from_xy(self.lon['data'], self.lat['data']) + fids = np.arange(len(self._lon['data'])) + fids = fids[self.read_axis_limits['x_min']:self.read_axis_limits['x_max']] + gdf = gpd.GeoDataFrame(index=pd.Index(name='FID', data=fids.ravel()), geometry=geometry, crs="EPSG:4326") + self.shapefile = gdf + + return gdf