NASA-IMPACT / veda-features-api

OGC Compliant WFS3 and MVT APIs
Other
2 stars 1 forks source link

Update features API with Alexey's 2019 and 2020 data #8

Closed abarciauskas-bgse closed 1 year ago

abarciauskas-bgse commented 1 year ago

AC:

Details

Current state:

year = 2019 # 2020
collection_prefix = f'EIS/other/feds-WesternUS/{year}/Largefire/00-latest'
files = client.list_objects_v2(Bucket=bucket, Prefix=collection_prefix)
first_object = files['Contents'][0]['Key']
filename = client.download_file(Bucket=bucket, Key=first_object, Filename=first_object.split('/')[-1])
# Fetch DB credentials output from Tim's stack and use them to populate this script:
!ogr2ogr -f "PostgreSQL" \
  PG:"host=HOST \
  dbname=DBNAME user=USER password=PASSWORD" "fireline.fgb" \
    -nln fire_boundearies_2019 -append
abarciauskas-bgse commented 1 year ago

I started to try and run tifeatures locally and I'm getting this error: asyncpg.exceptions.UndefinedTableError: relation "geometry_columns" does not exist

Also note I had to install postgis extension on my database. The tifeatures documentation may be incomplete as the setup locally does not include much instructions about how to setup the local postgres postgis database.

abarciauskas-bgse commented 1 year ago

I was able to get the tifeatures app to run locally after running these commands:

➜ psql postgis                 
psql (14.1, server 14.5 (Homebrew))
Type "help" for help.

postgis=# CREATE EXTENSION postgis;
CREATE EXTENSION

with DATABASE_URL=postgresql://postgres:@0.0.0.0:5432/postgis

and then I was able to insert into the database using:

ogr2ogr -f "PostgreSQL" \
  PG:"host=0.0.0.0 dbname=postgis user=postgres" \
  -t_srs EPSG:4326 \
  "../veda-documentation/fireline.fgb" \
  -nln fire_boundearies_2019
vincentsarago commented 1 year ago

sorry about that @abarciauskas-bgse, I'll try to update the documentation.

FYI: We are moving away from tifeatures/timvt to https://github.com/developmentseed/tipg (empty for now) which will have both mvt and features endpoints.

j08lue commented 1 year ago

see https://github.com/NASA-IMPACT/veda-documentation/blob/ab/add-cognito-auth-example/cognito_login_example.ipynb

Nice example, @abarciauskas-bgse!

Let me know when it would make sense to replace the ogr2ogr upload by a Python solution, for example with GeoDatatFrame.to_postgis. Should be pretty straightforward.

abarciauskas-bgse commented 1 year ago

@vincentsarago oh I wasn't expecting the documentation to be complete btw :) I realize that some of the "setup postgis" is left as an exercise to the reader (and I am a novice postgis user)

abarciauskas-bgse commented 1 year ago

I started to lookinto using GeoDataFrame.to_postgis but an error arose, see: https://github.com/NASA-IMPACT/veda-features-api/blob/ab/add-features-script/scripts/add_fire_features.ipynb

Also recapping some discussion from slack with Alexey, Bitnerd and Alex M: