Re: read shapefile in ncl

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Dec 09 2011 - 12:57:01 MST

I should have added more detailed information about how to get shapefiles from http://www.gadm.org

 - Go to http://www.gadm.org/country
 - In the "Country" pull-down menu, select the country of choice, "China"
 - Make sure "File format" is set to "shapefile"
 - Click on the "OK" button
 - Click on the big "Download" word.
 - This should start downloading a file called "CHN_ADM.zip"
 - At this point, you will either have a file called "CHN_ADM.zip", or, if your system automatically unzips the files, you will have a directory called "CHN_adm"
 - If you just have the "CHN_adm.zip" file, you need to unzip it with "unzip CHN_adm.zip"

You will have a directory CHN_adm with files:

CHN_adm0.dbf* CHN_adm0.shx* CHN_adm1.shp* CHN_adm2.sbx* CHN_adm3.sbn*
CHN_adm0.prj* CHN_adm1.dbf* CHN_adm1.shx* CHN_adm2.shp* CHN_adm3.sbx*
CHN_adm0.sbn* CHN_adm1.prj* CHN_adm2.dbf* CHN_adm2.shx* CHN_adm3.shp*
CHN_adm0.sbx* CHN_adm1.sbn* CHN_adm2.prj* CHN_adm3.dbf* CHN_adm3.shx*
CHN_adm0.shp* CHN_adm1.sbx* CHN_adm2.sbn* CHN_adm3.prj* CHN_readme.txt*

Usually the "adm0" file contains the outline for the country, while the other files contain outlines for smaller regions.

Example 8 on the page:

http://www.ncl.ucar.edu/Applications/shapefiles.shtml

has some functions for plotting these adm files.

--Mary

On Dec 9, 2011, at 10:57 AM, Mary Haley wrote:

> <China_masked_data-0.png>
> <China_masked_data-1.png>
> Hi Lei,
>
> There was something strange about the shapefile you were using. I tried to plot it and got a bunch of straight lines instead of a nice polyline defining the outline of China.
>
> I went to gadm.org/countryres to download a different shapefile for China. This gives you several shapefiles, and the one I used was "CHN_adm/CHN_adm0.shp". This contains the single outline for China, while the other *.shp files in that same directory contain other smaller regions.
>
> Please see the attached script and images. This script is a modifcation of the one you sent me.
>
> --Mary
> <era40_china_mod.ncl>
> On Dec 8, 2011, at 5:05 PM, Lei Meng wrote:
>
>> Hi Mary,
>> I never try to make a graph. The script creates a new .nc file and the thumbnail images were taken from the new generated nc file.
>> Thanks,
>> Lei
>>
>> On Thu, Dec 8, 2011 at 4:26 PM, Mary Haley <haley@ucar.edu> wrote:
>> Lei,
>>
>> In your NCL script, all the graphics code is commented out. Do you have a script where the graphics code is actually working?
>>
>> --Mary
>>
>> On Dec 8, 2011, at 2:13 PM, Lei Meng wrote:
>>
>>> Hi Mary,
>>> It has been uploaded. Thanks,
>>> Lei
>>>
>>> On Thu, Dec 8, 2011 at 3:43 PM, Mary Haley <haley@ucar.edu> wrote:
>>> Sorry, you need to "cd incoming" before you put the file.
>>>
>>> --Mary
>>>
>>> On Dec 8, 2011, at 11:54 AM, Lei Meng wrote:
>>>
>>>> Hi Mary,
>>>> I got the error message when uploading the file:
>>>> ftp> put ERA-40-V1-4-allyears-monthly.nc
>>>> local: ERA-40-V1-4-allyears-monthly.nc remote: ERA-40-V1-4-allyears-monthly.nc
>>>> 229 Entering Extended Passive Mode (|||49152|)
>>>> 553 Could not create file.
>>>> Thanks,
>>>> Lei
>>>>
>>>> On Thu, Dec 8, 2011 at 1:21 PM, Mary Haley <haley@ucar.edu> wrote:
>>>> Can you provide all the data file too?
>>>>
>>>> ftp ftp.cgd.ucar.edu
>>>> < login as anonymous, with your email as the password>
>>>> put ERA-40-V1-4-allyears-monthly.nc
>>>> quit
>>>>
>>>> I have to see where the missing values are getting set, and I can't do that without being able to run your script.
>>>>
>>>> Thanks,
>>>>
>>>> --Mary
>>>>
>>>> On Dec 8, 2011, at 11:12 AM, Lei Meng wrote:
>>>>
>>>>> Hi Mary,
>>>>> Attached is the script I used. Do I have several regions in my shapefile? I thought it is just boundary of China. Thanks,
>>>>> Lei
>>>>>
>>>>> On Thu, Dec 8, 2011 at 12:26 PM, Mary Haley <haley@ucar.edu> wrote:
>>>>>
>>>>> Lei,
>>>>>
>>>>> Thanks for providing the data files. Can you provide the script as well? It's hard to debug this based on a small thumbnail image.
>>>>>
>>>>> One thing that comes to mind is if you have several regions in your shapefile, you need to be careful that you don't set your data values to missing because they only fall in one of the regions.
>>>>>
>>>>> That is, once you find that a data point is inside one of your regions, make sure that this particular data value stays set, and that it doesn't get reset to missing just because it doesn't fall inside some other region.
>>>>>
>>>>> --Mary
>>>>>
>>>>>
>>>>> On Dec 8, 2011, at 9:38 AM, Lei Meng wrote:
>>>>>
>>>>> > Hi,
>>>>> > I was able to use a China shapefile to extract ERA40 soil moisture data for the whole country. But I found that extracted data within China contain missing data which should be valid data instead of missing value in ERA40. I attached screen shots of the extracted data and the original ERA40 data. I also attached the shapefiles I used to extract the data. Any suggestions? Thanks,
>>>>> > Lei
>>>>>
>>>>>
>>>>> <era40_china.ncl>
>>>>
>>>>
>>>
>>>
>>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Dec 9 12:57:13 2011

This archive was generated by hypermail 2.1.8 : Fri Dec 09 2011 - 13:09:09 MST