Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to draw concentric polygons/circles using large image? #289

Closed
rwtam121 opened this issue Jun 13, 2018 · 13 comments
Closed

Comments

@rwtam121
Copy link

Hi,

I was looking at the annotations documentation here: https://github.com/girder/large_image/blob/master/docs/annotations.md and was wondering if we could create a single polygon or a circle that has a polygon/circle within it. I ask because the nature of the annotations seems that if you put the points into the points array, a line will be drawn connecting the inner circle/polygon to the outer circle/polygon, like this:
image

From documentation the points are specified like this:
"points": [
[5,6,0],
[-17,6,0],
[56,-45,6]
]
But is there any special way for it to support concentric polygons without a connecting line?

@manthey
Copy link
Member

manthey commented Jun 14, 2018

Internally, polygons can be have holes. They can be specified like {"outer": [[5, 6, 0], [-17, 6, 0], [56, -45, 6]], "inner": [[[4, 5, 0], [2, 5, 0], [2, 1, 0]]]}, where the inner entry can have any number of lists, each of which is a separate hole. There currently isn't any user interface for drawing a hole in a polygon, and you can't currently edit a polygon with holes.

From the user interface, how would you specify that you want to add a hole to a polygon?

@rwtam121
Copy link
Author

Yeah, I saw that the large_image documentation didn't mention anything about creating holes. I was looking at GeoJSON's documentation and they noted that the polygons could be specified with holes, like what you said: With holes::

{ "type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}

I was kind of hoping I would be able to add a list of more points underneath the "points" header below to put holes in my polygon, but as you said I don't think that's possible in large_image:
{
"type": "polyline", # Exact string. Required
<id, label, lineColor, lineWidth> # Optional general shape properties
"points": [ # At least two points must be specified
[5,6,0], # Coordinate. At least two required
[-17,6,0],
[56,-45,6]
], [[[more points here]]]
"closed": true, # Boolean. Default is false. Optional
"fillColor": "rgba(0, 255, 0, 1)" # String. See note about colors. Optional
}

Thanks for the help though.

@manthey
Copy link
Member

manthey commented Jun 14, 2018

I've add OpenGeoscience/geojs#845 to eventually support this.

@rwtam121
Copy link
Author

rwtam121 commented Jun 15, 2018

Had another question on this...is it possible to install the Geospatial plugin in Girder and be able to make GeoJSON formatted query statements in the web API (rather than using large_image formatted statements)? I ask because the Geospatial plugin says it "enables the storage and querying of GeoJSON formatted geospatial data" so does this mean I can switch from:

large_image format:
{
"type": "polyline", # Exact string. Required
<id, label, lineColor, lineWidth> # Optional general shape properties
"points": [ # At least two points must be specified
[5,6,0], # Coordinate. At least two required
[-17,6,0],
[56,-45,6]
],
"closed": true, # Boolean. Default is false. Optional
"fillColor": "rgba(0, 255, 0, 1)" # String. See note about colors. Optional
}

to

GeoJSON format:
{
"type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
],
}

I know you said there's no interface to support hole generation, and this didn't work when I tried it, but just wondering if this was still an option.

@manthey
Copy link
Member

manthey commented Jun 18, 2018

The geospatial and large_image plugins use different data storage locations and types.

The large_image annotations are stored in a distinct Mongo collection (actually two collections: annotation and annotationelement). The data in large_image annotations are their own schema which includes element types that don't exist in GeoJSON.

The Girder geospatial plugin handles GeoJSON data stored in a 'geo' field in the item collection, and searches only within that field.

@rwtam121
Copy link
Author

rwtam121 commented Jun 18, 2018

I guess my question is that after I enabled the geospatial plugin and pressed rebuild and restart,
image
image

I was kind of expecting the geospatial option in the REST API documentation, or an annotation schema that includes geoJSON data. But I don't see those options even after the plugin was installed. The screenshot below shows no geoJSON option:
image

When going into annotation schema
image
I only see options for large_image annotations, but nothing for geoJSON even after the plugin was installed:
image

Am I expecting too much out of geoJSON, or is there something else I need to toggle to get it working? Sorry if the conversation went a little off topic from the large_image issue.

@dorukozturk
Copy link
Contributor

@rwtam121 You would see the geospatial endpoints under "item" since that plugin is adding new routes to items. Just expand the item endpoints.

@rwtam121
Copy link
Author

rwtam121 commented Jun 18, 2018

@dorukozturk Thanks for pointing me in the right direction! Sorry to keep moving off topic but I tried putting some geoJSON known to work in the geojson.io website (gets a square as seen in the below left):
image

and I went back to the REST API and put that json onto the image using PUT/item/{id}/geospatial.
image

But I got this error (TypeError: String indices must be integers):
image

The field looks like it contains valid GeoJSON (it worked within geojson.io) so I am missing something fundamental here--should I use PUT/item/{id}/geospatial to put the overlay on the items? Thanks for the help!

@dorukozturk
Copy link
Contributor

Sure, no problem. I think you only need the geometry part. Try it with the geometry portion of it. Something like:

{
        "type": "Polygon",
        "coordinates": [
          [
            [
              -86.484375,
              23.885837699862005
            ],
            [
              -73.47656249999999,
              23.885837699862005
            ],
            [
              -73.47656249999999,
              31.052933985705163
            ],
            [
              -86.484375,
              31.052933985705163
            ],
            [
              -86.484375,
              23.885837699862005
            ]
          ]
        ]
      }

@rwtam121
Copy link
Author

Hmmm, I still got the same error when doing that:
TypeError: TypeError('string indices must be integers',)",
I'm wondering what could it mean by string indices? We have a list of coordinates and key-value pairs, but I don't think I'm indexing anything with the command...

@rwtam121
Copy link
Author

Hi @dorukozturk ,

I was able to get the geospatial info from the coordinates with the help of girder/girder#2744, using PUT /item/{id}/geospatial. But this just sets the geospatial info for the object:
image

I'm wondering we could translate that geospatial info into an overlay on top of that item, much like in the annotations case. Is that currently supported? I scanned the REST API and I don't think we can translate the geospatial info into an annotation.

@dorukozturk
Copy link
Contributor

I am afraid that is currently not supported. At least I don't know an easy way to go about that.

@manthey
Copy link
Member

manthey commented Jun 29, 2022

Circle annotations are supported. Polygon annotations with holes are supported. Nested circles have to be specified as polygons with holes.

@manthey manthey closed this as completed Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants