home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 128222506

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/501#issuecomment-128222506 https://api.github.com/repos/pydata/xarray/issues/501 128222506 MDEyOklzc3VlQ29tbWVudDEyODIyMjUwNg== 1217238 2015-08-06T02:58:43Z 2015-08-06T02:58:43Z MEMBER

We'll probably release v0.6 in several weeks, once we have the key functionality we want for new the plotting module.

On Wed, Aug 5, 2015 at 7:24 PM, slharris notifications@github.com wrote:

This example is very helpful. Thank you.

I think the where() method you refer to will be very useful - When will the version 0.5.3 be released?

Thanks Sarah

On 31 July 2015 at 06:00, Stephan Hoyer notifications@github.com wrote:

rasterio and geopandas can be combined with xray to make converting shapefiles into raster masks pretty easy. Here's a quick demo: ``python import geopandas from rasterio import features from affine import Affine

def transform_from_latlon(lat, lon): lat = np.asarray(lat) lon = np.asarray(lon) trans = Affine.translation(lon[0], lat[0]) scale = Affine.scale(lon[1] - lon[0], lat[1] - lat[0]) return trans * scale

def rasterize(shapes, coords, fill=np.nan, *

_kwargs): """Rasterize a list of (geometry, fill_value) tuples onto the given xray coordinates. This only works for 1d latitude and longitude arrays. """ transform = transform_from_latlon(coords['latitude'], coords['longitude']) out_shape = (len(coords['latitude']), len(coords['longitude'])) raster = features.rasterize(shapes, out_shape=out_shape, fill=fill, transform=transform, *_kwargs) return xray.DataArray(raster, coords=coords, dims=('latitude', 'longitude'))

states =

geopandas.read_file('/Users/shoyer/Downloads/ne_10m_admin_1_states_provinces_lakes') geometries = states.query("admin == 'United States of America'").geometry shapes = [(shape, n) for n, shape in enumerate(geometries)]

ds = xray.Dataset(coords={'longitude': np.linspace(-125, -65, num=2000), 'latitude': np.linspace(50, 25, num=1000)}) ds['states'] = rasterize(shapes, ds.coords) plotting requires the dev version of xray

ds.states.plot()

Once you have the rasterized geometries, you can use them as arrays to do arithmetic: https://github.com/xray/xray/issues/503

When we figure out how to represent coordinate reference systems properly in xray we might add in a direct wrapper for some of these rasterio functions.

— Reply to this email directly or view it on GitHub https://github.com/xray/xray/issues/501#issuecomment-126461466.

Dr Sarah Harris Research Fellow School of Earth, Atmosphere and Environment Room 227, 9 Rainforest Walk Monash University Ph: 03 9902 4243 Email: sarah.harris@monash.edu Email%3Asarah.harris@monash.edu

— Reply to this email directly or view it on GitHub https://github.com/xray/xray/issues/501#issuecomment-128216372.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  98074194
Powered by Datasette · Queries took 78.251ms · About: xarray-datasette