kylebarron / landsat-cogeo-mosaic

Create mosaicJSON for Landsat imagery
https://kylebarron.dev/landsat-cogeo-mosaic/
MIT License
4 stars 0 forks source link

landsat-cogeo-mosaic index fails with error #17

Closed JesseCrocker closed 4 years ago

JesseCrocker commented 4 years ago

I'm trying to run

landsat-cogeo-mosaic index \
        --wrs-path data/WRS2_descending.shp \
        --scene-path data/scene_list.gz \
        --bounds '-180,-85,180,85' \
        --quadkey-zoom 8 \
        > $@

Using the latest geopands, 0.8.1 it fails with the following error

Traceback (most recent call last):
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/bin/landsat-cogeo-mosaic", line 8, in <module>
    sys.exit(main())
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/landsat_cogeo_mosaic/cli.py", line 296, in index
    _index = create_index(
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/landsat_cogeo_mosaic/index.py", line 38, in create_index
    joined = gpd.sjoin(pathrows, tiles, op='intersects')
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/geopandas/tools/sjoin.py", line 56, in sjoin
    _crs_mismatch_warn(left_df, right_df, stacklevel=3)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/geopandas/array.py", line 93, in _crs_mismatch_warn
    left_srs = left.crs.to_string()
AttributeError: 'str' object has no attribute 'to_string'

Using geopandas 0.7.0 it fails with a different error

Traceback (most recent call last):
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/bin/landsat-cogeo-mosaic", line 8, in <module>
    sys.exit(main())
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/landsat_cogeo_mosaic/cli.py", line 296, in index
    _index = create_index(
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/landsat_cogeo_mosaic/index.py", line 41, in create_index
    gdf = optimize_index(joined)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/landsat_cogeo_mosaic/index.py", line 73, in optimize_index
    return pd.concat(res_df)
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/pandas/core/reshape/concat.py", line 274, in concat
    op = _Concatenator(
  File "/Users/jesse/venvs/landsat-cogeo-mosaic/lib/python3.8/site-packages/pandas/core/reshape/concat.py", line 331, in __init__
    raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate

Both produces thousands of lines of

Shell is not a LinearRing
Shell is not a LinearRing
Shell is not a LinearRing
Shell is not a LinearRing
kylebarron commented 4 years ago

Shell is not a LinearRing

That means your geopandas isn't correctly installed https://github.com/geopandas/geopandas/issues/556

kylebarron commented 4 years ago

I think if you can reproduce the exception without seeing any Shell is not a LinearRing errors, then it's a bug

kylebarron commented 4 years ago

FYI I'm able to run the command without errors Oops, spoke too soon, but I get a different error than you

It is expected that you see these errors (I should quiet them):

/Users/kyle/github/mapping/landsat-cogeo-mosaic/landsat_cogeo_mosaic/index.py:94: UserWarning: Geometry is in a geographic CRS. Results from 'area' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.

As part of the index creation I compute the relative areas of intersecting landsat scenes, and it's fine for these purposes to do this in a geographic CRS

kylebarron commented 4 years ago

Maybe the most recent release of geopandas broke .intersection with a geographic CRS... anyways it works for me now and should be fixed on master.

Try with

pip install git+https://github.com/kylebarron/landsat-cogeo-mosaic
JesseCrocker commented 4 years ago

Got it working, thanks for the help. For reference, here's what i did:

    virtualenv $@
    source $@/bin/activate
    pip3 install numpy
    pip3 install --no-binary :all: shapely
    pip3 install geopandas keplergl_cli
    pip3 install 'git+https://github.com/kylebarron/landsat-cogeo-mosaic'