Color terrain on SpatialLines object made of sparse Lines Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!Write lines of text to a file in RRun R script from command lineHow to create SpatialLine objectPoint Pattern AnalysisValue of coordinates() for a SpatialPolygonsDataFrame object?How to make a SpatialLines object from undefined - but known - spatial sequence of points in R?Apply Data to SpatialLines Objectlabeling/ coloring elements/segments of a linnet objectR: Union Spatial Polygons won't remove separation line completelySpatial line start and end point in R
Multi tool use
Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?
Is the address of a local variable a constexpr?
What would be the ideal power source for a cybernetic eye?
Check which numbers satisfy the condition [A*B*C = A! + B! + C!]
How do I keep my slimes from escaping their pens?
When -s is used with third person singular. What's its use in this context?
Letter Boxed validator
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
How can players work together to take actions that are otherwise impossible?
Diagram with tikz
Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?
List *all* the tuples!
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Using et al. for a last / senior author rather than for a first author
Did Kevin spill real chili?
How widely used is the term Treppenwitz? Is it something that most Germans know?
Is there any avatar supposed to be born between the death of Krishna and the birth of Kalki?
3 doors, three guards, one stone
Single word antonym of "flightless"
Why are there no cargo aircraft with "flying wing" design?
Why is "Consequences inflicted." not a sentence?
What is this single-engine low-wing propeller plane?
Bonus calculation: Am I making a mountain out of a molehill?
How do I mention the quality of my school without bragging
Color terrain on SpatialLines object made of sparse Lines
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!Write lines of text to a file in RRun R script from command lineHow to create SpatialLine objectPoint Pattern AnalysisValue of coordinates() for a SpatialPolygonsDataFrame object?How to make a SpatialLines object from undefined - but known - spatial sequence of points in R?Apply Data to SpatialLines Objectlabeling/ coloring elements/segments of a linnet objectR: Union Spatial Polygons won't remove separation line completelySpatial line start and end point in R
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a high-resolution coastline shapefile from NOAA that covers a large chunk of the globe. My aim is to:
1 - Clip this dataset to a smaller area (already achieved OK);
2 - Overlay the bounded area on a base R plot (still having problems).
Here's my code:
library(rgeos)
library(rgdal)
download.file(url = 'https://dnc.nga.mil/DNCSiteContent/Shapefiles/shapefile01.zip', destfile = '~/Desktop/shapefile01.zip')
unzip('~/Desktop/shapefile01.zip', exdir = '~/Desktop/shapefile01')
closeAllConnections()
system('rm -rf ~/Desktop/shapefile01.zip')
targetfolder <- dir('~/Desktop', pattern = 'shapefile01', full.names = TRUE) # need full directory path for rgdal::readOGR
shape <- rgdal::readOGR(dsn = targetfolder, layer = 'cd01')
bbx <- rgeos::readWKT('POLYGON((-42.05 -23.03, -41.95 -23.03, -41.95 -22.93, -42.05 -22.93, -42.05 -23.03))')
proj4string(bbx) <- proj4string(shape)
mysite <- rgeos::gIntersection(shape, bbx)
plot(mysite)
What I ideally want here is to color the terrain on the map, such that it would look like this (here edited with Photoshop):
But mysite
, an object of class SpatialLines
with 28 line segments that should be a single thing, but in reality are not connected. So when I plot the whole object, the line contour of this coastal area appears to be just fine. But because they're a bunch of smaller line segments, R doesn't know how to put them together so I can fill the terrain. Is there a way to tell R to color fill the continent? Maybe combine all these segments into one continuous continental contour?
By the way, I would ideally like to do this in base R because this will be later added (i.e. overlaid) onto another plot with a color gradient fill for the ocean around the same geographical area (generated from another spatial file).
UPDATE
Using the spatstat
package I can now visualise all the line segments very easily, so I thought it would be nice to update this here to help visualise the problem. Here's the code:
library(spatstat)
mysite2 <- spatstat::as.psp(mysite)
plot(mysite2)
Makes sense? I think it would be nice to have a permanent solution because that's the nature of these high-res shoreline shapefiles provided by NOAA.
r sp rgdal spatstat rgeo-shapefile
add a comment |
I have a high-resolution coastline shapefile from NOAA that covers a large chunk of the globe. My aim is to:
1 - Clip this dataset to a smaller area (already achieved OK);
2 - Overlay the bounded area on a base R plot (still having problems).
Here's my code:
library(rgeos)
library(rgdal)
download.file(url = 'https://dnc.nga.mil/DNCSiteContent/Shapefiles/shapefile01.zip', destfile = '~/Desktop/shapefile01.zip')
unzip('~/Desktop/shapefile01.zip', exdir = '~/Desktop/shapefile01')
closeAllConnections()
system('rm -rf ~/Desktop/shapefile01.zip')
targetfolder <- dir('~/Desktop', pattern = 'shapefile01', full.names = TRUE) # need full directory path for rgdal::readOGR
shape <- rgdal::readOGR(dsn = targetfolder, layer = 'cd01')
bbx <- rgeos::readWKT('POLYGON((-42.05 -23.03, -41.95 -23.03, -41.95 -22.93, -42.05 -22.93, -42.05 -23.03))')
proj4string(bbx) <- proj4string(shape)
mysite <- rgeos::gIntersection(shape, bbx)
plot(mysite)
What I ideally want here is to color the terrain on the map, such that it would look like this (here edited with Photoshop):
But mysite
, an object of class SpatialLines
with 28 line segments that should be a single thing, but in reality are not connected. So when I plot the whole object, the line contour of this coastal area appears to be just fine. But because they're a bunch of smaller line segments, R doesn't know how to put them together so I can fill the terrain. Is there a way to tell R to color fill the continent? Maybe combine all these segments into one continuous continental contour?
By the way, I would ideally like to do this in base R because this will be later added (i.e. overlaid) onto another plot with a color gradient fill for the ocean around the same geographical area (generated from another spatial file).
UPDATE
Using the spatstat
package I can now visualise all the line segments very easily, so I thought it would be nice to update this here to help visualise the problem. Here's the code:
library(spatstat)
mysite2 <- spatstat::as.psp(mysite)
plot(mysite2)
Makes sense? I think it would be nice to have a permanent solution because that's the nature of these high-res shoreline shapefiles provided by NOAA.
r sp rgdal spatstat rgeo-shapefile
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05
add a comment |
I have a high-resolution coastline shapefile from NOAA that covers a large chunk of the globe. My aim is to:
1 - Clip this dataset to a smaller area (already achieved OK);
2 - Overlay the bounded area on a base R plot (still having problems).
Here's my code:
library(rgeos)
library(rgdal)
download.file(url = 'https://dnc.nga.mil/DNCSiteContent/Shapefiles/shapefile01.zip', destfile = '~/Desktop/shapefile01.zip')
unzip('~/Desktop/shapefile01.zip', exdir = '~/Desktop/shapefile01')
closeAllConnections()
system('rm -rf ~/Desktop/shapefile01.zip')
targetfolder <- dir('~/Desktop', pattern = 'shapefile01', full.names = TRUE) # need full directory path for rgdal::readOGR
shape <- rgdal::readOGR(dsn = targetfolder, layer = 'cd01')
bbx <- rgeos::readWKT('POLYGON((-42.05 -23.03, -41.95 -23.03, -41.95 -22.93, -42.05 -22.93, -42.05 -23.03))')
proj4string(bbx) <- proj4string(shape)
mysite <- rgeos::gIntersection(shape, bbx)
plot(mysite)
What I ideally want here is to color the terrain on the map, such that it would look like this (here edited with Photoshop):
But mysite
, an object of class SpatialLines
with 28 line segments that should be a single thing, but in reality are not connected. So when I plot the whole object, the line contour of this coastal area appears to be just fine. But because they're a bunch of smaller line segments, R doesn't know how to put them together so I can fill the terrain. Is there a way to tell R to color fill the continent? Maybe combine all these segments into one continuous continental contour?
By the way, I would ideally like to do this in base R because this will be later added (i.e. overlaid) onto another plot with a color gradient fill for the ocean around the same geographical area (generated from another spatial file).
UPDATE
Using the spatstat
package I can now visualise all the line segments very easily, so I thought it would be nice to update this here to help visualise the problem. Here's the code:
library(spatstat)
mysite2 <- spatstat::as.psp(mysite)
plot(mysite2)
Makes sense? I think it would be nice to have a permanent solution because that's the nature of these high-res shoreline shapefiles provided by NOAA.
r sp rgdal spatstat rgeo-shapefile
I have a high-resolution coastline shapefile from NOAA that covers a large chunk of the globe. My aim is to:
1 - Clip this dataset to a smaller area (already achieved OK);
2 - Overlay the bounded area on a base R plot (still having problems).
Here's my code:
library(rgeos)
library(rgdal)
download.file(url = 'https://dnc.nga.mil/DNCSiteContent/Shapefiles/shapefile01.zip', destfile = '~/Desktop/shapefile01.zip')
unzip('~/Desktop/shapefile01.zip', exdir = '~/Desktop/shapefile01')
closeAllConnections()
system('rm -rf ~/Desktop/shapefile01.zip')
targetfolder <- dir('~/Desktop', pattern = 'shapefile01', full.names = TRUE) # need full directory path for rgdal::readOGR
shape <- rgdal::readOGR(dsn = targetfolder, layer = 'cd01')
bbx <- rgeos::readWKT('POLYGON((-42.05 -23.03, -41.95 -23.03, -41.95 -22.93, -42.05 -22.93, -42.05 -23.03))')
proj4string(bbx) <- proj4string(shape)
mysite <- rgeos::gIntersection(shape, bbx)
plot(mysite)
What I ideally want here is to color the terrain on the map, such that it would look like this (here edited with Photoshop):
But mysite
, an object of class SpatialLines
with 28 line segments that should be a single thing, but in reality are not connected. So when I plot the whole object, the line contour of this coastal area appears to be just fine. But because they're a bunch of smaller line segments, R doesn't know how to put them together so I can fill the terrain. Is there a way to tell R to color fill the continent? Maybe combine all these segments into one continuous continental contour?
By the way, I would ideally like to do this in base R because this will be later added (i.e. overlaid) onto another plot with a color gradient fill for the ocean around the same geographical area (generated from another spatial file).
UPDATE
Using the spatstat
package I can now visualise all the line segments very easily, so I thought it would be nice to update this here to help visualise the problem. Here's the code:
library(spatstat)
mysite2 <- spatstat::as.psp(mysite)
plot(mysite2)
Makes sense? I think it would be nice to have a permanent solution because that's the nature of these high-res shoreline shapefiles provided by NOAA.
r sp rgdal spatstat rgeo-shapefile
r sp rgdal spatstat rgeo-shapefile
edited Mar 23 at 8:53
dbarneche
asked Mar 22 at 8:38
dbarnechedbarneche
148126
148126
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05
add a comment |
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295733%2fcolor-terrain-on-spatiallines-object-made-of-sparse-lines%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295733%2fcolor-terrain-on-spatiallines-object-made-of-sparse-lines%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
LzEXTM00CYH2l,hxgZ9ndjHPBL6hqKzcdMbqc2BR,JItIAE
In general, for a given shoreline, how do you know which direction the sea is and which direction is land? Do any shapefiles or rasters exist for the land and sea?
– awchisholm
Mar 23 at 12:05