Closed kcpevey closed 5 years ago
Context: I'm using the annotators to pull data from the drawing. It comes back via point_stream which is a PointDraw data type. In order to reproject it at that point, I have to do a some massaging to point_stream.data and then I'm using cartopy to convert. But it seems like there should be a more direct approach using gv?
I've run into the same issue. I found the following code from the GSSHA_Workflow notebook (an older notebook) that doesn't seem to work:
projected = gv.operation.project(point_stream.element, projection=ccrs.PlateCarree())
However, some of the newer examples use a gv.util.project_extents
which does seem to work but only for a box:
bbox = list(gv.util.project_extents((xs[0], ys[0], xs[2], ys[1]), ccrs.GOOGLE_MERCATOR, ccrs.PlateCarree()))
I've just been using pyproj:
from pyproj import Proj, transform
in_proj = Proj(init='epsg:3857')
out_proj = Proj(init='epsg:4269')
xs, ys = point_stream.element.array().T
projected_points = [transform(in_proj, out_proj, x, y) for x, y in zip(xs, ys)]
I suppose you could use the project_extents
function and just repeat the point:
xs, ys = point_stream.element.array().T
x, y, _, _ = gv.util.project_extents((xs[0], ys[0], xs[0], ys[0]), ccrs.GOOGLE_MERCATOR, ccrs.PlateCarree())
@sdc50 I ran into those same issues!
Discussed during our meeting today - I was misunderstanding the terms involved.
crs
- defines the projection that the data is currently in
projection
- defines the destination projection that we are attempting to project onto
@sdc50 had a versioning issue which may resolve his problem. Once you confirm, I'm ready to close.
I updated to geoviews 1.5.4a1 and can confirm that it works.
What is the best practice for singular or vectorized coordinate conversions? I think I can accomplish this in geoviews, but would using cartopy directly be a better approach?