2323import logging
2424import warnings
2525from pathlib import Path
26- from typing import Any , Literal , Union
26+ from typing import Any , Literal , Optional , Union
2727
2828import cartopy
2929import cartopy .crs as ccrs
5252
5353
5454class Centroids :
55- """Contains vector centroids as a GeoDataFrame
56-
57- Attributes
58- ----------
59- lat : np.array
60- Latitudinal coordinates in the specified CRS (can be any unit).
61- lon : np.array
62- Longitudinal coordinates in the specified CRS (can be any unit).
63- crs : pyproj.CRS
64- Coordinate reference system. Default: EPSG:4326 (WGS84)
65- region_id : np.array, optional
66- Numeric country (or region) codes. Default: None
67- on_land : np.array, optional
68- Boolean array indicating on land (True) or off shore (False). Default: None
69- """
55+ """Contains vector centroids as a GeoDataFrame"""
7056
7157 def __init__ (
7258 self ,
@@ -116,13 +102,13 @@ def __init__(
116102 self .set_on_land (source = on_land , overwrite = True )
117103
118104 @property
119- def lat (self ):
120- """Return latitudes """
105+ def lat (self ) -> np . array :
106+ """Latitudinal coordinates in the specified CRS (can be any unit). """
121107 return self .gdf .geometry .y .values
122108
123109 @property
124- def lon (self ):
125- """Return longitudes """
110+ def lon (self ) -> np . array :
111+ """Longitudinal coordinates in the specified CRS (can be any unit). """
126112 return self .gdf .geometry .x .values
127113
128114 @property
@@ -131,26 +117,26 @@ def geometry(self):
131117 return self .gdf ["geometry" ]
132118
133119 @property
134- def on_land (self ):
135- """Get the on_land property """
120+ def on_land (self ) -> Optional [ np . array ] :
121+ """Boolean array indicating on land (True) or off shore (False). Default: None """
136122 if "on_land" not in self .gdf :
137123 return None
138124 if self .gdf ["on_land" ].isna ().all ():
139125 return None
140126 return self .gdf ["on_land" ].values
141127
142128 @property
143- def region_id (self ):
144- """Get the assigned region_id """
129+ def region_id (self ) -> Optional [ np . array ] :
130+ """Numeric country (or region) codes. Default: None """
145131 if "region_id" not in self .gdf :
146132 return None
147133 if self .gdf ["region_id" ].isna ().all ():
148134 return None
149135 return self .gdf ["region_id" ].values
150136
151137 @property
152- def crs (self ):
153- """Get the crs """
138+ def crs (self ) -> CRS :
139+ """Coordinate reference system. Default: EPSG:4326 (WGS84) """
154140 return self .gdf .crs
155141
156142 @property
0 commit comments