Skip to main content
deleted 470 characters in body
Source Link
Ben
  • 67
  • 6

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Edit I get something similarclose to the intended outcome in Earth Engine using the following:

var dataset = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
                  .filter(ee.Filter.date('2010-01-01', '2013-01-01'));
var npp = dataset.select('annualNPP');
var npp_time_mean = npp.mean()

// random points to create a FeatureCollection
var p1 = ee.Geometry.Point([-100.353, 39.094]);
var p2 = ee.Geometry.Point([-105.133, 38.03]);
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)]));

var out = npp_time_meannpp.select(['annualNPP']).sampleRegions({
  collection: pts,
  properties: ['value']['SiteID'],
  geometries: true,
  scale: 1000
})

The output is a table with columns system:index, annualNPP and .geo, though I would like to be able to add a column for each point in the feature collection while retaining the original columns of the feature in the table.

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Edit I get something similar to the intended outcome in Earth Engine using the following:

var dataset = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
                  .filter(ee.Filter.date('2010-01-01', '2013-01-01'));
var npp = dataset.select('annualNPP');
var npp_time_mean = npp.mean()

// random points to create a FeatureCollection
var p1 = ee.Geometry.Point([-100.353, 39.094]);
var p2 = ee.Geometry.Point([-105.133, 38.03]);
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)]));

var out = npp_time_mean.select(['annualNPP']).sampleRegions({
  collection: pts,
  properties: ['value'],
  scale: 1000
})

The output is a table with columns system:index, annualNPP and .geo, though I would like to be able to add a column for each point in the feature collection while retaining the original columns of the feature in the table.

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Edit I get something close to the intended outcome in Earth Engine using the following:

var dataset = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
                  .filter(ee.Filter.date('2010-01-01', '2013-01-01'));
var npp = dataset.select('annualNPP').mean();
var out = npp.select(['annualNPP']).sampleRegions({
  collection: pts,
  properties: ['SiteID'],
  geometries: true,
  scale: 1000
})
added 894 characters in body
Source Link
Ben
  • 67
  • 6

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Edit I get something similar to the intended outcome in Earth Engine using the following:

var dataset = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
                  .filter(ee.Filter.date('2010-01-01', '2013-01-01'));
var npp = dataset.select('annualNPP');
var npp_time_mean = npp.mean()

// random points to create a FeatureCollection
var p1 = ee.Geometry.Point([-100.353, 39.094]);
var p2 = ee.Geometry.Point([-105.133, 38.03]);
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)]));

var out = npp_time_mean.select(['annualNPP']).sampleRegions({
  collection: pts,
  properties: ['value'],
  scale: 1000
})

The output is a table with columns system:index, annualNPP and .geo, though I would like to be able to add a column for each point in the feature collection while retaining the original columns of the feature in the table.

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Edit I get something similar to the intended outcome in Earth Engine using the following:

var dataset = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
                  .filter(ee.Filter.date('2010-01-01', '2013-01-01'));
var npp = dataset.select('annualNPP');
var npp_time_mean = npp.mean()

// random points to create a FeatureCollection
var p1 = ee.Geometry.Point([-100.353, 39.094]);
var p2 = ee.Geometry.Point([-105.133, 38.03]);
var pts = ee.FeatureCollection(ee.List([ee.Feature(p1),ee.Feature(p2)]));

var out = npp_time_mean.select(['annualNPP']).sampleRegions({
  collection: pts,
  properties: ['value'],
  scale: 1000
})

The output is a table with columns system:index, annualNPP and .geo, though I would like to be able to add a column for each point in the feature collection while retaining the original columns of the feature in the table.

added 1 character in body
Source Link
Ben
  • 67
  • 6

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPPNPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get(‘annual_npp’'annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP)
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get(‘annual_npp’).getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

I am trying to extract values from an ImageCollection for a set of coordinates in Google Earth Engine using the Python API.

First, I set up my EE environment:

import ee
import pprint
ee.Authenticate()
ee.Initialize()

Then I load the image collection and points. Pts is intended to be read into a table with latitude, longitude, and siteID as columns.

img = ee.ImageCollection('UMT/NTSG/v2/MODIS/NPP')
pts = ee.FeatureCollection('users/name/sites_unique.csv');

The image collection contains many images, each representing a year. I would like to iterate through each year and extract the associated NPP (band: ‘annual_npp’) for each point in pts. I anticipate this looking like (pseudocode):

For year in [2010, 2011, 2012, 2013]:
    img_selection = img.select(year = yr)
    output = img_selection.sample(pts, 1000).get('annual_npp').getInfo()

Does anyone know a generalizable way to extract this information from an ImageCollection?

Source Link
Ben
  • 67
  • 6
Loading