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

Are there built-in methods for writing geometry files? #4

Open
SorooshMani-NOAA opened this issue Jan 19, 2022 · 3 comments
Open

Are there built-in methods for writing geometry files? #4

SorooshMani-NOAA opened this issue Jan 19, 2022 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@SorooshMani-NOAA
Copy link
Collaborator

For example when one fetches data for isotachs or windswath, is there an easy way to write it to disk as Shapefile? Of course one can always use Geopandas or Fiona or OGR to do it, but it would be nice if part of that functionality could be added into this package.

Maybe add Geopandas is too much since it has a lot of dependencies when you install it in the environment, but Fiona is already installed for your current dependencies and a method could be added to write out the fetched Shapely objects in case it doesn't already exist.

@ghost ghost added the question Further information is requested label Jan 19, 2022
@ghost
Copy link

ghost commented Jan 19, 2022

that's a good idea, but the default environment doesn't currently have fiona or geopandas.

However, we could maybe add an optional dependency for fiona / geopandas, such as importing locally within the writing function and raising an error like "fiona must be installed in order to write to a spatial file" if the user calls the writing function without having it installed.

I think xarray does something very similar if you try to read a NetCDF file and don't have netcdf4 installed

@ghost ghost added the enhancement New feature or request label Jan 19, 2022
@SorooshMani-NOAA
Copy link
Collaborator Author

For some reason I thought fiona was installed on my env when installing StormEvents. But Now that I checked again it's not there. Sorry, my mistake!

But having an optional dependency is a good idea for this.

@ghost
Copy link

ghost commented Jan 19, 2022

https://github.com/pydata/xarray/blob/d3b6aa6d8b997df115a53c001d00222a0f92f63a/xarray/backends/plugins.py
^ here is the way that xarray does it for engines

import xarray

xarray.open_dataset("/home/zrb/Data/COASTAL_Act/runs/run_20211027_florence_besttrack_250msubset_quadrature/perturbations.nc")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zrb/environments/test/lib/python3.10/site-packages/xarray/backends/api.py", line 479, in open_dataset
    engine = plugins.guess_engine(filename_or_obj)
  File "/home/zrb/environments/test/lib/python3.10/site-packages/xarray/backends/plugins.py", line 155, in guess_engine
    raise ValueError(error_msg)
ValueError: found the following matches with the input file in xarray's IO backends: ['netcdf4', 'h5netcdf']. But their dependencies may not be installed, see:
http://xarray.pydata.org/en/stable/user-guide/io.html 
http://xarray.pydata.org/en/stable/getting-started-guide/installing.html

@ghost ghost self-assigned this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant