earthaccess icon indicating copy to clipboard operation
earthaccess copied to clipboard

Add method to convert results enabling GeoDataFrame.explore() to be used for creation of interactive maps

Open ebolch opened this issue 2 years ago • 9 comments

I have a rough example in this notebook. The end goal would be to have a simple function that would create a geodataframe and then an interactive plot, like:

results = earthaccess.search_data()
earthaccess.explore(results)

A few additional options could be things like plotting browse images or a way to limit the quantity of polygons/images displayed. This output is the interactive map from the above notebook after removing a few layers: concurrent_data_snip2

ebolch avatar Sep 21 '23 16:09 ebolch

Thanks for the suggestion, that's a really cool idea that would be great for improving data accessibility!

We'll want to consider how this would affect earthaccess's dependencies.

MattF-NSIDC avatar Sep 21 '23 17:09 MattF-NSIDC

I think we could easily support something like this either as a plugin, or as optional dependencies following at pattern like:

try:
     import optional_package
except ImportError:
    optional_package = None


def function_that_uses_optional_package():
   if optional_package is None:
      raise ImportError('Optional Package is required to call this function')
      
   # function code...

jhkennedy avatar Oct 13 '23 22:10 jhkennedy

I like this idea but we should consider how it would work for all data granules. I'm thinking of ICESat-2 and other track data. Maybe we define these types of data as multi-lines.

andypbarrett avatar Oct 13 '23 23:10 andypbarrett

This would be really useful! Is there currently a recommended approach to go from earthaccess search results to a geodataframe?

For example:

gf = gpd.GeoDataFrame.from_features(results.geojson(), crs='EPSG:4326')

Note: results.to_dict() is the syntax MS planetary computer uses (https://planetarycomputer.microsoft.com/docs/quickstarts/reading-stac/), but results.geojson() is what asf_search does (https://github.com/asfadmin/Discovery-asf_search/blob/bee8d92631780a988cbb1988266270241ebea23f/asf_search/ASFSearchResults.py#L23)

It seems a straightforward approach could be to include STAC as an output from CMR (https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html), which is a GeoJSON feature collection and therefore can therefore be easily converted to a geodataframe.

scottyhq avatar Nov 28 '23 23:11 scottyhq

 gf = gpd.GeoDataFrame.from_features(results.geojson(), crs='EPSG:4326')

:clap: yes, I'd love to be able to do this line and use it frequently with asf_search. @iamdonovan also recently asked about this [edited for clarity]:

should I suggest/request a "to_dataframe" method?

jhkennedy avatar Mar 29 '24 19:03 jhkennedy

This somewhat exists in the explore branch that @betolink was working on, although its part of the SearchWidget class. I think it would be valuable even separate from the integration of an explore feature. There's a slightly modified version of that code in this module that LP DAAC used for a tutorial.

ebolch avatar Apr 02 '24 19:04 ebolch