IllinoisStateGeologicalSurvey / keras-spatial

Provides a SpatialDataGenerator class for accessing spatial data.
18 stars 11 forks source link

Invalid CRS - Quickstart #2

Open ClaudeCoulombe opened 3 years ago

ClaudeCoulombe commented 3 years ago

Executing the last instruction arr = next(gen) of the Quickstart.ipynb, I've got a CRSerror:

CRSError: Invalid CRS: CRS.from_wkt('PROJCRS["NAD83_HARN_Illinois_East_ftUS",BASEGEOGCRS["NAD83",DATUM["North American Datum 1983",ELLIPSOID["GRS 1980",6378137,298.257222101004,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199

Versions of GDAL and rasterio

GDAL 2.2.3, released 2017/11/20

rasterio 1.1.5

ClaudeCoulombe commented 3 years ago

Similar error with the basic_example.py with the same instruction arr = next(gen)

CRSError: Invalid CRS: CRS.from_wkt('BOUNDCRS[SOURCECRS[PROJCRS["NAD83(HARN) / Illinois East (ftUS)",BASEGEOGCRS["NAD83(HARN)",DATUM["NAD83 (High Accuracy Reference Network)",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4152]],CONVERSION["unnamed",METHOD["Transverse Mercator",ID["EPSG",9807]],PARAMETER["Latitude of natural origin",36.6666666666667,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",-88.3333333333333,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["Scale factor at natural origin",0.999975,SCALEUNIT["unity",1],ID["EPSG",8805]],PARAMETER["False easting",984250,LENGTHUNIT["US survey foot",0.304800609601219],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["US survey foot",0.304800609601219],ID["EPSG",8807]]],CS["Cartesian",2],AXIS["x",east,ORDER[1],LENGTHUNIT["US survey foot",0.304800609601219]],AXIS["y",north,ORDER[2],LENGTHUNIT["US survey foot",0.304800609601219]],ID["EPSG",3443]]],TARGETCRS[GEOGCRS["WGS 84",DATUM["World Geodetic System 1984",ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS["ellipsoidal",2],AXIS["latitude",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["longitude",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]]],ABRIDGEDTRANSFORMATION["Transformation from NAD83(HARN) to WGS84",METHOD["Position Vector transformation (geog2D domain)",ID["EPSG",9606]],PARAMETER["X-axis translation",0,ID["EPSG",8605]],PARAMETER["Y-axis translation",0,ID["EPSG",8606]],PARAMETER["Z-axis translation",0,ID["EPSG",8607]],PARAMETER["X-axis rotation",0,ID["EPSG",8608]],PARAMETER["Y-axis rotation",0,ID["EPSG",8609]],PARAMETER["Z-axis rotation",0,ID["EPSG",8610]],PARAMETER["Scale difference",1,ID["EPSG",8611]]]]')

​Versions of GDAL and rasterio

GDAL 2.2.3, released 2017/11/20

rasterio 1.1.5

jterstriep commented 3 years ago

Thanks for reporting the error. I tried the code from the notebook and it worked in my environment. I suspect you are seeing a problem with your installation of GDAL. You might try opening one of the sources using rasterio directly.

Unfortunately, heading out for vacation tomorrow and will be gone for a week. I can try and provide additional assistance when I get back.

Jeff

On Mon, Jul 13, 2020 at 4:23 PM Claude COULOMBE notifications@github.com wrote:

Executing the last instruction next(gen) of the Quickstart.ipynb, I've got a CRSerror:

CRSError: Invalid CRS: CRS.from_wkt('PROJCRS["NAD83_HARN_Illinois_East_ftUS",BASEGEOGCRS["NAD83",DATUM["North American Datum 1983",ELLIPSOID["GRS 1980",6378137,298.257222101004,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/IllinoisStateGeologicalSurvey/keras-spatial/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATUV3BAB3PMZHM2FPKQ3ILR3N3LRANCNFSM4OY4B36A .

ClaudeCoulombe commented 3 years ago

Thank you for the quick response and your suggestion. I also suspect GDAL to be the cause of the problem. Enjoy your vacation.

When you return from your vacation, it would be nice if you could answer the questions below?

Are there specific problems with GDAL 2.2.3 and rasterio 1.1.5?

Is there a recommended way to install or update GDAL (Linux and Mac OS)?

Claude

sparkvilla commented 3 years ago

I also encountered the same error at the end of the Quickstart.ipynb after the arr = next(gen) instruction. Running the same code with another file input (sentinel2) I could spot the problem in this line:

https://github.com/IllinoisStateGeologicalSurvey/keras-spatial/blob/0df82f8392fa55e6fb830258098513eb5fb0803b/src/keras_spatial/datagen.py#L258

The rasterio WarpedVRT class accepts a crs parameter in the form of: crs='EPSG:3857'

The output of df.crs is instead:

<Projected CRS: PROJCS["NAD83_HARN_Illinois_East_ftUS",GEOGCS["NAD ...>
Name: NAD83_HARN_Illinois_East_ftUS
Axis Info [cartesian]:
- E[east]: Easting (US survey foot)
- N[north]: Northing (US survey foot)
Area of Use:
- undefined
Coordinate Operation:
- name: unnamed
- method: Transverse Mercator
Datum: North American Datum 1983
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

I changed the previous crs argument of line 258 to crs=f'EPSG:{df.crs.to_epsg()}' which renders to 'EPSG:32737 for my input file. Not sure if this will generalize but it fixed the problem, i.e. now I can access the arr from the arr = next(gen) instruction.

I still get an error with Quickstart.ipynb. However in this case the f'EPSG:{df.crs.to_epsg()}'renders to 'EPSG:None' which would explain why it fails..

I am running GDAL 2.2.3 and rasterio 1.1.5 on ubuntu 18.04

ClaudeCoulombe commented 3 years ago

@sparkvilla Thank you!

I'm not very familiar with coordinate reference system (CRS) which seems a bit picky.

Claude