Web Content Display

Web Content Display (CoastWatch User Forum)

The NOAA CoastWatch Forum provides information in several categories.  The information is relevant to CoastWatch products and software (https://coastwatch.noaa.gov)  and vary in technical details.  For questions and issues not addressed here,  start a thread in the appropriate category or contact the CoastWatch HelpDesk (coastwatch.info@noaa.gov).  Please note our Privacy Policy (https://www.noaa.gov/privacy.html) and that this is a public forum.  All information is voluntarily and anonymous submissions are accepted pending review prior to posting. 

Forums

Back

RE: shapefiles in R - weird things are happening

ES
Eva Schemmel, modified 4 Years ago.

shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts

When I try the R tutorial with my own shapefile with multiple regions for the Marianas. I get an added sketched boundary. I am trying to figure out how to rectify this. Is my problem that you can only map to one polygon at a time and I have ten separate regions within this shapefile? Or is it something in the R code that is adding an additional polygon to the lat and long coordinates? Or maybe something I did making the file in ArcGIS (but it looks good in Arcmaps so I don't think this is the issue).

MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Hi Eva,

Yes I think it's trying to link the features together. You might need to make a loop to plot each feature individually. Let me give it a try.

MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Could you also attach the other files from the Marianas boundary? Unfortunately the .shp files is not enough.

ES
Eva Schemmel, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts
MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Ok, here's something that looks like it's working. I commented all the ERDDAP stuff.
​​​​​​​basically, you plot the basemap first, then in a loop, you plot the boundary of each feature in your shapefile.

ES
Eva Schemmel, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts
Thank you Melanie! That works for me.

On Tue, Oct 27, 2020 at 1:49 PM Melanie Abecassis <VLab.Notifications@noaa.gov> wrote:

Ok, here's something that looks like it's working. I commented all the ERDDAP stuff.
​​​​​​​basically, you plot the basemap first, then in a loop, you plot the boundary of each feature in your shapefile.


--
Melanie Abecassis CoastWatch Virtual Lab Forum https://vlab.noaa.gov/web/coastwatch/coastwatch-knowledge-base/forum/-/message_boards/view_message/12336418 VLab.Notifications@noaa.gov



--
Eva Schemmel, PhD
Fisheries Biologist
Pacific Islands Fisheries Science Center
NOAA Fisheries
808-725-5513
ES
Eva Schemmel, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts
Hi Melanie and virtual lab,
I tried updating the same R code to use a different SST data set and do not get any error messages, but the SST does not plot across the entire shapefile. I am using the same data and time step as when I mapped it in Panoply, so I know the data exists. Can someone look to see what the issue is?
Thank you,
Eva

On Tue, Oct 27, 2020 at 1:57 PM Eva Schemmel <VLab.Notifications@noaa.gov> wrote:
Thank you Melanie! That works for me.

On Tue, Oct 27, 2020 at 1:49 PM Melanie Abecassis <VLab.Notifications@noaa.gov> wrote:

Ok, here's something that looks like it's working. I commented all the ERDDAP stuff.
​​​​​​​basically, you plot the basemap first, then in a loop, you plot the boundary of each feature in your shapefile.


--
Melanie Abecassis CoastWatch Virtual Lab Forum https://vlab.noaa.gov/web/coastwatch/coastwatch-knowledge-base/forum/-/message_boards/view_message/12336418VLab.Notifications@noaa.gov


--
Eva Schemmel, PhD
Fisheries Biologist
Pacific Islands Fisheries Science Center
NOAA Fisheries
808-725-5513

--
Eva Schemmel CoastWatch Virtual Lab Forum http://vlab.noaa.gov/web/coastwatch/coastwatch-knowledge-base/forum/-/message_boards/view_message/12336446VLab.Notifications@noaa.gov


--
Eva Schemmel, PhD
Fisheries Biologist
Pacific Islands Fisheries Science Center
NOAA Fisheries
808-725-5513

Attachments:

MS
Michael Soracco, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 39 Join Date: 8/11/16 Recent Posts

Hi Eva,

The first thing that comes to mind is identifying the differences in the SST datafiles.  Was one of the datasets 0 to 360 and the other -180 to 180?  I've seen your shapefile around 146E and does not cross the dateline.  Can you provide the URLs to the two SSTs?  

MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Hi Eva, there were a couple of issues:

1. This new SST dataset is in celsius, so no need to convert.

2. because you are downloading and plotting 10 polygons separately, you need to set the range of values for the color scale in advance and apply it (ie the same range) to all the polygons. Each 'test' polygon is going to have a different range of sst values from one to the next, so you can't use that to set the range.

MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Forgot to add: you can also play with the layout line to make the proportions look better based on the shape of your region.

ES
Eva Schemmel, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts
Hi Melanie,
This is very appreciated. Unfortunately, I have another issue I can't resolve. I am trying to get the yearly SST means for each region now. I updated the code to include every month for 2019 but only 2 months are being selected and averaged for SST, the first two. I can't figure out what I am missing. Is there a special way that you are supposed to handle time data in R that I am missing?
Eva

On Wed, Oct 28, 2020 at 5:03 AM Melanie Abecassis <VLab.Notifications@noaa.gov> wrote:

Forgot to add: you can also play with the layout line to make the proportions look better based on the shape of your region.


--
Melanie Abecassis CoastWatch Virtual Lab Forum https://vlab.noaa.gov/web/coastwatch/coastwatch-knowledge-base/forum/-/message_boards/view_message/12343895VLab.Notifications@noaa.gov


--
Eva Schemmel, PhD
Fisheries Biologist
Pacific Islands Fisheries Science Center
NOAA Fisheries
808-725-5513

Attachments:

MA
Melanie Abecassis, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 65 Join Date: 6/12/17 Recent Posts

Hi Eva, tcoord needs to be the range of dates. so just put your first and last and it should work.

ES
Eva Schemmel, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 13 Join Date: 4/13/20 Recent Posts
Hi,
I am wanting to do some more complicated summaries like total chlor a in a region instead of means, mins and maximums. Is this just a sum function? I created a list within the loop to get min, max, and means for each region but I am not sure how to get a total value. I was thinking that the total value would be more informative for relative productivity in each region. Let me know what you think or if there are other ways to get at a region's relative productivity.


On Wed, Oct 28, 2020 at 11:08 AM Melanie Abecassis <VLab.Notifications@noaa.gov> wrote:

Hi Eva, tcoord needs to be the range of dates. so just put your first and last and it should work.


--
Melanie Abecassis CoastWatch Virtual Lab Forum https://vlab.noaa.gov/web/coastwatch/coastwatch-knowledge-base/forum/-/message_boards/view_message/12348036VLab.Notifications@noaa.gov


--
Eva Schemmel, PhD
Fisheries Biologist
Pacific Islands Fisheries Science Center
NOAA Fisheries
808-725-5513
CW
Cara Wilson, modified 4 Years ago.

RE: shapefiles in R - weird things are happening

Youngling Posts: 41 Join Date: 6/12/17 Recent Posts

Eva - 

The simple answer to your question is that the sum function in R will sum up the vectors of values, but I'm not thinking that will be very helpful to you.  Chlorophyll  is not linearly distributed - valid values range for 0.1 to 200 so summing values is really not going to be very helpful.  Because of the non linearity its customary to plot the log chl, which makes the values more normally distributed.  Though in the oligotrophic ocean the range of chl is small, and one can often get away with not logging the data, and this might be the case for your region. What is the primary question you are trying to address?