mapbox / robosat

Semantic segmentation on aerial and satellite imagery. Extracts features such as: buildings, parking lots, roads, water, clouds
MIT License
2.02k stars 382 forks source link

rs merge: fail on 'Merging components' #176

Closed alektros closed 4 years ago

alektros commented 5 years ago

Hello! Many thanks to the developers for this amazing framework! It is very helpful!

I faced with problem when use rs merge (stage 'Merging components'):

Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/src/app/robosat/tools/main.py", line 58, in args.func(args) File "/usr/src/app/robosat/tools/merge.py", line 79, in main area = int(round(project(merged, "epsg:4326", "esri:54009").area)) File "/usr/src/app/robosat/spatial/core.py", line 21, in project project = functools.partial(pyproj.transform, pyproj.Proj(init=source), pyproj.Proj(init=target)) File "/opt/venv/lib/python3.6/site-packages/pyproj/proj.py", line 295, in init self.crs = CRS.from_user_input(projparams if projparams is not None else kwargs) File "/opt/venv/lib/python3.6/site-packages/pyproj/crs.py", line 224, in from_user_input return cls(**value) File "/opt/venv/lib/python3.6/site-packages/pyproj/crs.py", line 146, in init super(CRS, self).init(projstring) File "pyproj/_crs.pyx", line 317, in pyproj._crs._CRS.init pyproj.exceptions.CRSError: Invalid projection: +init=esri:54009 +type=crs: (Internal Proj Error: proj_create: cannot expand +init=esri:54009 +type=crs)

What is problem? Maybe I have wrong environment setup?

daniel-j-h commented 5 years ago

Hey, glad you like robosat! :)

It looks like you are running the rs merge tool: in it we project into an equal-area projection so that we can calculate the merged shape's area.

Now it seems like pyproj has problems with the equal-area projection and is not able to transform properly. I don't have a solution off the top of my head and it used to work properly before.

I suggest the following:

daniel-j-h commented 4 years ago

@alektros any updates from your side here?

alektros commented 4 years ago

@alektros any updates from your side here?

Hello! While i am testing and experimenting with other functionality, so i had not back to this issue. But probably, i will work with this issue again in few weeks

daniel-j-h commented 4 years ago

@alektros any updates here? Can you reproduce with our pre-built docker images?

Venka97 commented 4 years ago

Hey @daniel-j-h ,

I had the same issue, I changed a few lines in the project method of core.py and now it works.

transformer = pyproj.Transformer.from_crs(source, target) return shapely.ops.transform(transformer.transform, shape) In place of project = functools.partial(pyproj.transform, pyproj.Proj(init=source), pyproj.Proj(init=target)) return shapely.ops.transform(project, shape)

I found the solution here: https://github.com/pyproj4/pyproj/issues/341

daniel-j-h commented 4 years ago

Coolio! Thanks @Venka97 for keeping us posted! :smile:

Do you want to open a pull request with your suggested changes? Thanks! :hugs:

Venka97 commented 4 years ago

Sure!