[ncl-talk] Visualizing shapefiles with multiple polygons

Adam Sisco aws0006 at uah.edu
Thu May 30 15:05:57 MDT 2019


Hi Lyndz,

[1] Yes, the shapefile I linked in the original request was a "dummy" file
I created in a GIS for testing/troubleshooting purposes. The shapefiles I
am actually interested in are composed of > 100 features.

[2] I think shapefiles being composed of hundreds or even thousands of
features might limit the practicality of splitting shapefiles into their
component features.

[3] Thanks for the script with a proposed work around. While it is
sufficient for the "dummy" shapefile, I will need to experiment with
whether or not coloring the geometries in that way might interfere with any
underlying maps, etc. as I suspect some issues could arise.

Best,
Adam


On Thu, May 30, 2019 at 10:59 AM Lyndz <olagueralyndonmark429 at gmail.com>
wrote:

> Hi,
>
> I would like to clarify some things regarding this query.
>
> [1] Did you create the shapefile using a GIS software?
>
> [2] Why not split the shapefile into two: inner rectangle and the other
> hollow rectangle.
> Then, plot them separately?
>
> [3] You can also use NCL to color each polygon geometry using the attached
> script.
>
> --
> Lyndz
>
>
>
> On Thu, May 30, 2019 at 9:57 PM Adam Sisco <aws0006 at uah.edu> wrote:
>
>> Hi Rick,
>>
>> Thank you so much for taking a look at the underlying code for me. I
>> really appreciate it. I also understand the constraints that the pivot to
>> Python might place on resolving this bug. For anyone else who might be
>> seeking a quick open source solution for a "shapefile island"
>> visualization, Spatial Features for R (https://github.com/r-spatial/sf)
>> is able to properly display the interior feature (see attached figure). R
>> script below:
>>
>> ****************************************************
>> library(sf)
>> library(ggplot2)
>>
>> test <- st_read("***PATH TO SHAPEFILE***/test_shapefile.shp")
>> ggplot() + geom_sf(data = test, fill = "lightgreen")
>> ****************************************************
>>
>> Best,
>> Adam
>>
>>
>> On Wed, May 29, 2019 at 10:47 PM Rick Brownrigg <brownrig at ucar.edu>
>> wrote:
>>
>>> Hi Adam,
>>>
>>> Firstly, much thanks for providing the concise, nicely illustrated
>>> example of the problem!
>>>
>>> After looking through the code, I can believe this is a bug, and
>>> unfortunately, not one easily fixed. The underlying code properly knows how
>>> to decode shapefile "features" that are comprised of multiple "segments" or
>>> closed loops. But in drawing, it treats each sub-polygon independently.
>>> This works well, for example, for a coastal nation with a mainland and many
>>> islands, but it does not work for the case you provided, one with an outer
>>> hull containing interior islands/regions. Alas, the code that
>>> gsn_add_shapefile_polygons() is based upon does not provide interface to
>>> specify multiple nested interior loops. We can file this as a github issue,
>>> but with our current prioritization, I can't promise a timely fix.
>>>
>>> I wish I had a better response...
>>>
>>> Rick
>>>
>>>
>>> On Wed, May 29, 2019 at 11:15 AM Adam Sisco <aws0006 at uah.edu> wrote:
>>>
>>>> Hello NCL users,
>>>>
>>>> I have a question regarding the visualization of shapefiles using NCL.
>>>> For the sake of this help request, I have constructed a sample shapefile
>>>> with a simplified geometry to illustrate the issue I am having. The
>>>> shapefile contains a polygon within the opening of larger polygon, but I'm
>>>> not sure NCL's gsn_add_shapefile_polygons function is capturing the
>>>> polygon-within-polygon nature of this shapefile. So that my issue can be
>>>> reproduced, I have attached:
>>>>
>>>>    1. The sample shapefile I am attempting to plot
>>>>    2. The desired visualization of the shapefile
>>>>    3. The visualization that results from the
>>>>    gsn_add_shapefile_polygons function
>>>>    4. The NCL script used to plot the shapefile
>>>>
>>>> I suspect that a more nuanced approach may be needed to produce the
>>>> proper visualization. If this is within the capabilities of NCL, I would
>>>> appreciate any assistance you can offer. I am using NCL 6.4.0 on a Windows
>>>> machine.
>>>>
>>>> ********************
>>>> begin
>>>>   wks  = gsn_open_wks("x11","shapefile_testing")
>>>>
>>>>   res = True
>>>>   res at gsnDraw = False
>>>>   res at gsnFrame = False
>>>>   res at gsnMaximize = True
>>>>
>>>>   res at mpMinLonF = -110
>>>>   res at mpMaxLonF = -75
>>>>   res at mpMinLatF = 25
>>>>   res at mpMaxLatF = 55
>>>>
>>>>   plot = gsn_csm_map(wks,res)
>>>>
>>>>   polyRes = True
>>>>   polyRes at gsEdgesOn = True
>>>>
>>>>   poly = gsn_add_shapefile_polygons(wks,plot,"***PATH TO
>>>> SHAPEFILE***/test_shapefile.shp",polyRes)
>>>>
>>>>   draw(plot)
>>>>   frame(wks)
>>>> end
>>>> ********************
>>>>
>>>> Regards,
>>>>
>>>> *Adam Sisco*
>>>> Research Associate
>>>> NASA MSFC IMPACT
>>>> University of Alabama in Huntsville
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190530/95f2e9ba/attachment.html>


More information about the ncl-talk mailing list