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

Specify a 'datetime' column when converting from (Geo)DataFrame to FeatureCollection #950

Closed
janpisl opened this issue Feb 28, 2022 · 2 comments
Labels
Feature Request New feature or request
Projects

Comments

@janpisl
Copy link

janpisl commented Feb 28, 2022

Description

When I convert from (Geo)DataFrame that contains a column with date to FeatureCollection, I cannot filter by date because the date is only stored in properties of the FeatureCollection.

Source code

gdf_radd = gpd.read_file('RADD_alerts.gpkg')
alerts_subset = gdf_radd.query(''20210101 < date < 2021-03-03')
#alerts subset returns a non-empty GeoDataFrame containing rows within selected dates

ee_radd = geemap.geopandas_to_ee(gdf_radd)
alerts_subset_ee = ee_radd.filterDate(ee.Date('2021-01-01'), ee.Date('2021-03-03'))
#alerts_subset_ee is empty. it is not possible to filter by date

Desired behaviour

#I would be able to specify a column that contains date/datetime when converting from (Geo)DataFrame to GEE FeatureCollection
ee_radd = geemap.geopandas_to_ee(gdf_radd, datetime=gdf_radd.date)

Possible sketch of a solution

def set_date(feature):
    date = feature.get('date').getInfo()
    year, month, day = [int(i) for i in date.split()[0].split('/')]
    date_mls = ee.Date.fromYMD(year, month, day).millis()
    feature = feature.set("system:time_start", date_mls)
    return feature

ee_radd_with_dates = ee_radd.map(set_date)
@janpisl janpisl added the Feature Request New feature or request label Feb 28, 2022
giswqs added a commit that referenced this issue Mar 1, 2022
@giswqs giswqs added this to To do in geemap via automation Mar 1, 2022
@giswqs
Copy link
Member

giswqs commented Mar 1, 2022

This feature has been implemented.

gdf_to_ee(gdf, geodesic=True, date=None, date_format='YYYY-MM-dd')

image

@giswqs giswqs closed this as completed Mar 1, 2022
geemap automation moved this from To do to Done Mar 1, 2022
@janpisl
Copy link
Author

janpisl commented Mar 3, 2022

Amazing! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
geemap
  
Done
Development

No branches or pull requests

2 participants