geonotebook icon indicating copy to clipboard operation
geonotebook copied to clipboard

Displaying Vector Data

Open ghost opened this issue 8 years ago • 11 comments

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) `

ghost avatar Oct 12 '17 14:10 ghost

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

dorukozturk avatar Oct 12 '17 14:10 dorukozturk

@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)

ghost avatar Oct 12 '17 15:10 ghost

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.

jbeezley avatar Oct 12 '17 15:10 jbeezley

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'

ghost avatar Oct 12 '17 15:10 ghost

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]).

jbeezley avatar Oct 12 '17 15:10 jbeezley

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.

ghost avatar Oct 12 '17 16:10 ghost

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.

jbeezley avatar Oct 12 '17 17:10 jbeezley

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.

ghost avatar Nov 01 '17 19:11 ghost

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

dorukozturk avatar Nov 01 '17 19:11 dorukozturk

@dorukozturk yeah thanks I'll check it out.

ghost avatar Nov 01 '17 19:11 ghost

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

ghost avatar Nov 01 '17 23:11 ghost