Open ghost opened 6 years ago
@DavidLeifer There are some integration test notebooks which you can check. Specifically this one.
@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)
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.
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'
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])
.
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.
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.
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.
@DavidLeifer We did a bug fix on not displaying layers. Can you pull the latest version and try?
@dorukozturk yeah thanks I'll check it out.
That did not work for me, still having the same issue.
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) `