1414from morecantile import TileMatrixSet
1515from morecantile import tms as morecantile_tms
1616from morecantile .defaults import TileMatrixSets
17+ from rasterio .crs import CRS
18+ from rio_tiler .constants import WGS84_CRS
1719from rio_tiler .io import BaseReader , MultiBandReader , MultiBaseReader , Reader
1820from rio_tiler .models import BandStatistics , Bounds , Info
1921from rio_tiler .types import ColorMapType
3537 BandsParams ,
3638 BidxExprParams ,
3739 ColorMapParams ,
40+ CRSParams ,
3841 DatasetParams ,
3942 DatasetPathParams ,
4043 DefaultDependency ,
@@ -367,6 +370,7 @@ def info_geojson(
367370 with rasterio .Env (** env ):
368371 with self .reader (src_path , ** reader_params ) as src_dst :
369372 return Feature (
373+ type = "Feature" ,
370374 geometry = Polygon .from_bounds (* src_dst .geographic_bounds ),
371375 properties = src_dst .info (),
372376 )
@@ -428,6 +432,7 @@ def geojson_statistics(
428432 ..., description = "GeoJSON Feature or FeatureCollection."
429433 ),
430434 src_path = Depends (self .path_dependency ),
435+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
431436 layer_params = Depends (self .layer_dependency ),
432437 dataset_params = Depends (self .dataset_dependency ),
433438 image_params = Depends (self .img_dependency ),
@@ -439,13 +444,14 @@ def geojson_statistics(
439444 """Get Statistics from a geojson feature or featureCollection."""
440445 fc = geojson
441446 if isinstance (fc , Feature ):
442- fc = FeatureCollection (features = [geojson ])
447+ fc = FeatureCollection (type = "FeatureCollection" , features = [geojson ])
443448
444449 with rasterio .Env (** env ):
445450 with self .reader (src_path , ** reader_params ) as src_dst :
446451 for feature in fc :
447452 data = src_dst .feature (
448453 feature .dict (exclude_none = True ),
454+ shape_crs = coord_crs or WGS84_CRS ,
449455 ** layer_params ,
450456 ** image_params ,
451457 ** dataset_params ,
@@ -845,17 +851,20 @@ def point(
845851 lon : float = Path (..., description = "Longitude" ),
846852 lat : float = Path (..., description = "Latitude" ),
847853 src_path = Depends (self .path_dependency ),
854+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
848855 layer_params = Depends (self .layer_dependency ),
849856 dataset_params = Depends (self .dataset_dependency ),
850857 reader_params = Depends (self .reader_dependency ),
851858 env = Depends (self .environment_dependency ),
852859 ):
853860 """Get Point value for a dataset."""
861+
854862 with rasterio .Env (** env ):
855863 with self .reader (src_path , ** reader_params ) as src_dst :
856864 pts = src_dst .point (
857865 lon ,
858866 lat ,
867+ coord_crs = coord_crs or WGS84_CRS ,
859868 ** layer_params ,
860869 ** dataset_params ,
861870 )
@@ -949,6 +958,7 @@ def part(
949958 maxy : float = Path (..., description = "Bounding box max Y" ),
950959 format : ImageType = Query (..., description = "Output image type." ),
951960 src_path = Depends (self .path_dependency ),
961+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
952962 layer_params = Depends (self .layer_dependency ),
953963 dataset_params = Depends (self .dataset_dependency ),
954964 image_params = Depends (self .img_dependency ),
@@ -969,6 +979,7 @@ def part(
969979 with self .reader (src_path , ** reader_params ) as src_dst :
970980 image = src_dst .part (
971981 [minx , miny , maxx , maxy ],
982+ bounds_crs = coord_crs or WGS84_CRS ,
972983 ** layer_params ,
973984 ** image_params ,
974985 ** dataset_params ,
@@ -1014,6 +1025,7 @@ def geojson_crop(
10141025 None , description = "Output image type. Default is auto."
10151026 ),
10161027 src_path = Depends (self .path_dependency ),
1028+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
10171029 layer_params = Depends (self .layer_dependency ),
10181030 dataset_params = Depends (self .dataset_dependency ),
10191031 image_params = Depends (self .img_dependency ),
@@ -1034,6 +1046,7 @@ def geojson_crop(
10341046 with self .reader (src_path , ** reader_params ) as src_dst :
10351047 image = src_dst .feature (
10361048 geojson .dict (exclude_none = True ),
1049+ shape_crs = coord_crs or WGS84_CRS ,
10371050 ** layer_params ,
10381051 ** image_params ,
10391052 ** dataset_params ,
@@ -1135,6 +1148,7 @@ def info_geojson(
11351148 with rasterio .Env (** env ):
11361149 with self .reader (src_path , ** reader_params ) as src_dst :
11371150 return Feature (
1151+ type = "Feature" ,
11381152 geometry = Polygon .from_bounds (* src_dst .geographic_bounds ),
11391153 properties = {
11401154 asset : asset_info
@@ -1254,6 +1268,7 @@ def geojson_statistics(
12541268 ..., description = "GeoJSON Feature or FeatureCollection."
12551269 ),
12561270 src_path = Depends (self .path_dependency ),
1271+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
12571272 layer_params = Depends (AssetsBidxExprParamsOptional ),
12581273 dataset_params = Depends (self .dataset_dependency ),
12591274 image_params = Depends (self .img_dependency ),
@@ -1265,7 +1280,7 @@ def geojson_statistics(
12651280 """Get Statistics from a geojson feature or featureCollection."""
12661281 fc = geojson
12671282 if isinstance (fc , Feature ):
1268- fc = FeatureCollection (features = [geojson ])
1283+ fc = FeatureCollection (type = "FeatureCollection" , features = [geojson ])
12691284
12701285 with rasterio .Env (** env ):
12711286 with self .reader (src_path , ** reader_params ) as src_dst :
@@ -1276,6 +1291,7 @@ def geojson_statistics(
12761291 for feature in fc :
12771292 data = src_dst .feature (
12781293 feature .dict (exclude_none = True ),
1294+ shape_crs = coord_crs or WGS84_CRS ,
12791295 ** layer_params ,
12801296 ** image_params ,
12811297 ** dataset_params ,
@@ -1370,6 +1386,7 @@ def info_geojson(
13701386 with rasterio .Env (** env ):
13711387 with self .reader (src_path , ** reader_params ) as src_dst :
13721388 return Feature (
1389+ type = "Feature" ,
13731390 geometry = Polygon .from_bounds (* src_dst .geographic_bounds ),
13741391 properties = src_dst .info (** bands_params ),
13751392 )
@@ -1444,6 +1461,7 @@ def geojson_statistics(
14441461 ..., description = "GeoJSON Feature or FeatureCollection."
14451462 ),
14461463 src_path = Depends (self .path_dependency ),
1464+ coord_crs : Optional [CRS ] = Depends (CRSParams ),
14471465 bands_params = Depends (BandsExprParamsOptional ),
14481466 dataset_params = Depends (self .dataset_dependency ),
14491467 image_params = Depends (self .img_dependency ),
@@ -1455,7 +1473,7 @@ def geojson_statistics(
14551473 """Get Statistics from a geojson feature or featureCollection."""
14561474 fc = geojson
14571475 if isinstance (fc , Feature ):
1458- fc = FeatureCollection (features = [geojson ])
1476+ fc = FeatureCollection (type = "FeatureCollection" , features = [geojson ])
14591477
14601478 with rasterio .Env (** env ):
14611479 with self .reader (src_path , ** reader_params ) as src_dst :
@@ -1466,6 +1484,7 @@ def geojson_statistics(
14661484 for feature in fc :
14671485 data = src_dst .feature (
14681486 feature .dict (exclude_none = True ),
1487+ shape_crs = coord_crs or WGS84_CRS ,
14691488 ** bands_params ,
14701489 ** image_params ,
14711490 ** dataset_params ,
0 commit comments