OpenGeoscience / geonotebook

A Jupyter notebook extension for geospatial visualization and analysis
Apache License 2.0
1.08k stars 141 forks source link

Displaying Vector Data #150

Open ghost opened 6 years ago

ghost commented 6 years ago

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 commented 6 years ago

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

ghost commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

ghost commented 6 years ago

@dorukozturk yeah thanks I'll check it out.

ghost commented 6 years ago

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