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

Displaying Vector Data #150

Open
ghost opened this issue Oct 12, 2017 · 11 comments
Open

Displaying Vector Data #150

ghost opened this issue Oct 12, 2017 · 11 comments

Comments

@ghost
Copy link

ghost commented Oct 12, 2017

This isn't really an issue, but how would I display a series of X,Y coordinates of points? Would it be possible to add a pop up window to the display?

The docs go into depth about displaying raster data but don't really cover vector data:

`from geonotebook.wrappers import RasterData

rd = RasterData('file:///path/to/file.tiff')
M.add_layer(rd[1, 2, 3], opacity=1.0, gamma=2.5)
`

@dorukozturk
Copy link
Contributor

@DavidLeifer There are some integration test notebooks which you can check.
Specifically this one.

@ghost ghost closed this as completed Oct 12, 2017
@ghost ghost reopened this Oct 12, 2017
@ghost
Copy link
Author

ghost commented Oct 12, 2017

@dorukozturk does that mean you could pass a pandas data frame of x,y coordinates in?

Like instead of:
M.add_annotation('point', [0, 0])

Do this:
df = [-10,10]
M.add_annotation('point', df)

@jbeezley
Copy link

I don't think directly passing in a dataframe will work. The API expects an iterable object containing two numbers. I'm not an expert in pandas, but I'm sure there is some way to get that from a dataframe. Also, each point will need to be added individually as there is no "bulk" operation for generation annotations.

@ghost
Copy link
Author

ghost commented Oct 12, 2017

So I've saved the pandas dataframe as a geojson. This notebook gives reference as to add geojson rectangles onto a map. I think this should work for point data as well right?

When I try to add it to the map as a layer I get:

AttributeError: 'dict' object has no attribute 'name'

@jbeezley
Copy link

How are you trying to add the geojson data? There is a difference between a vector data layer and an annotation which may be causing confusion here. As I recall, the vector data needs to load from a file of some sort (anything that fiona supports) and has to be represented in EPSG:4326 (latitude/longitude). The only way to add annotations programatically is through the a call like M.add_annotation('point', [0, 0]).

@ghost
Copy link
Author

ghost commented Oct 12, 2017

I've converted my pandas data frame of column 'x' and column 'y' coordinates into a geojson file using this.

So I have a geojson file saved in the geojson variable. The vector data layer should be able to add the points with the following line, correct?

v = VectorData(geojson)
M.add_layer(v)

That would be disappointing if you had to add each individual point using annotations. I guess I'm trying to add the points programatically.

@jbeezley
Copy link

The VectorData constructor takes either the path to a file or a fiona object not a dictionary. It might be possible to generate a fiona object in memory, but I suspect the easiest way to move forward would be to write the contents of the geojson object you have into a file and pass that file name to the VectorData constructor.

@ghost
Copy link
Author

ghost commented Nov 1, 2017

I've created a geojson file.
After I enter:
v = VectorData(geojson)
M.add_layer(v)
I get:
<promise.promise.Promise at 0x7fe7ac075910>
But no points on the map. The geojson opens up in qgis without an issue. It has the proper projection: EPSG:4326.

@dorukozturk
Copy link
Contributor

@DavidLeifer We did a bug fix on not displaying layers. Can you pull the latest version and try?

@ghost
Copy link
Author

ghost commented Nov 1, 2017

@dorukozturk yeah thanks I'll check it out.

@ghost
Copy link
Author

ghost commented Nov 1, 2017

That did not work for me, still having the same issue.

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

2 participants