[gdal-dev] how to convert shapefile to netcdf?

Chris Barker chris.barker at noaa.gov
Mon May 28 11:39:02 PDT 2012


On Mon, May 28, 2012 at 10:16 AM, Chao YUE <chaoyuejoy at gmail.com> wrote:

> I have a shapefile of boreal foest (which further contains some ecoregion
> types) in North America and I want to like convert it to a NetCDF file (or
> numpy masked array)

Well, what's in the shape file? polygons? You'll need to know more
about what the data model is in the shapefile. try orginfo to see
what's in them.

But a few ideas:

If polygons, gdalrasterize may help -- it will create a raster "mask"
of  the polygon(s) in the shapefile.

Otherwise, you might use ogr (or pyshapefile) to read the shapefiles,
and go from there. If you need something like gdalrasterize, but it
for some reason isn't quite right, you could read the shapefiles in
python, then render them with PIL to give you a way to customize hw
it's done. You can convert a PIL image to a numpy array pretty easily
from there.

HTH,
  -Chris







 with a desired spatial resolution (let's say 0.5 degree)
> and then use this information to extract corresponding data from a global
> NetCDF file. I spent past two days trying to find information online but
> still have no clues. If anybody has done something similar, any hints or
> suggestions are greatly appreciated. Thanks a lot.
>
> best regards,
>
> Chao
> --
> ***********************************************************************************
> Chao YUE
> Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
> UMR 1572 CEA-CNRS-UVSQ
> Batiment 712 - Pe 119
> 91191 GIF Sur YVETTE Cedex
> Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
> ************************************************************************************
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the gdal-dev mailing list