Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7562931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:32:06+00:00 2026-05-30T13:32:06+00:00

I have a shapefile with regions with polygons, and can successfully use PlotOnStaticMap like

  • 0

I have a shapefile with regions with polygons, and can successfully use PlotOnStaticMap like this:

#Map <- GetMap.bbox(bb$  #Just to show I read "Map" here
shp_0 <- rgdal::readOGR(dsn="dir", layer="TheLayer")
shp_1 <- shp_0@polygons[[i1]]  # where i1=the region I'm looking at
shp_2 <- shp_1@Polygons[[i2]]  # where i2=the polygon I want to plot
tbl_coords_i2 <- data.frame(shp_2@coords)
tbl_coords_i2$color <- colors()[33]  # red
tmp <- PlotOnStaticMap(lat=tbl_coords_i2$X2, lon=tbl_coords_i2$X1, cex=0.5, pch=15, col=tbl_coords_i2$color, MyMap=Map, add=FALSE, NEWMAP=FALSE, FUN=points)

But what I really want is to plot the areas filled with red, like this:

tmp <- PlotPolysOnStaticMap(polys=shp_2, col=colors()[33], MyMap=Map, border = NULL, lwd=0.25, add=FALSE, NEWMAP=FALSE)

But that gives the error “Error in polys[, “Y”] : object of type ‘S4’ is not subsettable” How should this be done instead?

  • shp_0 is a “SpatialPolygonsDataframe”
  • shp_1 is a “Polygons”
  • shp_2 is a “Polygon”

Sorry for not providing reproducible code.

Thank you very much.

/Chris

Update: I just realized that the “shp” in PlotPolysOnStaticMap(shp) should be a dataframe with the columns “X” and “Y”, i.e. not a shapefile as I previously assumed.

Update 2: Even though I use “border=NA”, I get the red polygons with black borders. Anyone know how to get rid of the borders?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:32:08+00:00Added an answer on May 30, 2026 at 1:32 pm

    For the benefit of others, I here present the workaround I found: I printed “PlotPolysOnMap” and pasted it into my own function “PlotPolysOnMap2”. Then in the new function (not shared), I manually set border=NA (it was border=border). Then the polygons were plotted without lines around them. This “ugly fix” probably upsets the programmers more skilled than I am, but I needed to finish today…

    /Chris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Shapefile map of Maryland separated by zipcode. What I'd like to
i have an application, i registred it and i can start it like this
i have 3 shapefile ready in a map file, and rendering it on mapserver.
I have some shapefile (demographic/heat map data in the USA, such as crime in
I have a ESRI shapefile (from here: http://pubs.usgs.gov/ds/425/ ). I looking to use python
I have a shapefile with 50+ different polygonal shapes (representing 50+ different regions) and
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have had to write my first proper multithreaded coded recently, and realised just how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.