The slot for “plotOrder” comes up as 1 instead of a vector with length specific to my data The 2019 Stack Overflow Developer Survey Results Are InSubset a SpatialPolygonsDataFrame by ID in R?Convert a spatial polygon object to data frame using RSpatial weight matrix with boundary effects in R?Dissolving/Unifying Ill Behaved/Irregular Polygons in RData frame to SpatialPolygonsDataFrame with multiple polygons“Hole” argument ignored in call to Polygon functionUnique SpatialPolygons object with multiple polygons slots in RBuilding multiple extents as polygons from lat/long list values in RGroup and aggregate SpatialPolygonsDataFrame by column in RGroup and union polygons that share a border in R
Why doesn't shell automatically fix "useless use of cat"?
Falsification in Math vs Science
Flight paths in orbit around Ceres?
Why does the nucleus not repel itself?
Match Roman Numerals
Using xargs with pdftk
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Cooking pasta in a water boiler
Can we generate random numbers using irrational numbers like π and e?
What is the most efficient way to store a numeric range?
Is it correct to say the Neural Networks are an alternative way of performing Maximum Likelihood Estimation? if not, why?
Geography at the pixel level
Worn-tile Scrabble
I am an eight letter word. What am I?
Relationship between Gromov-Witten and Taubes' Gromov invariant
How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?
Did any laptop computers have a built-in 5 1/4 inch floppy drive?
Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
A word that means fill it to the required quantity
Why doesn't UInt have a toDouble()?
Is an up-to-date browser secure on an out-of-date OS?
How do you keep chess fun when your opponent constantly defeats?
Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?
The slot for “plotOrder” comes up as 1 instead of a vector with length specific to my data
The 2019 Stack Overflow Developer Survey Results Are InSubset a SpatialPolygonsDataFrame by ID in R?Convert a spatial polygon object to data frame using RSpatial weight matrix with boundary effects in R?Dissolving/Unifying Ill Behaved/Irregular Polygons in RData frame to SpatialPolygonsDataFrame with multiple polygons“Hole” argument ignored in call to Polygon functionUnique SpatialPolygons object with multiple polygons slots in RBuilding multiple extents as polygons from lat/long list values in RGroup and aggregate SpatialPolygonsDataFrame by column in RGroup and union polygons that share a border in R
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
My goal is to find neighbors from my SpatialPolygons object using the poly2nb()
command from the sp
package in R.
This is my code thus far:
p <- s_gis %>%
select(long, lat) %>%
Polygon()
ps <- Polygons(list(p), 1000)
sps <- SpatialPolygons(list(ps))
where s_gis is my dataset. I'm otherwise able to make a successful SpatialPolygons object except for the fact that the slot for plotOrder reads 1, instead of 636353 like it is in my dataset.
Running the poly2nb()
commands returns an error Error in sp$mbxv[i]:(n * 2) : argument of length 0
which I'm assuming is coming from the fact that it's finding 0 neighbors given that I only have a plotOrder of 1.
How do I modify the plotOrder?
In addition, regarding my error message from the poly2nb()
command, if the problem runs deeper, can someone shed some insight as to why?
I have also tried ps@plotOrder <- s_gis$order
to no avail.
EDIT:
#get lat, long, and groupid
s_gis_latlon <- s_gis %>%
select(long,lat, group)
#group lists by group id
p_groups <- split(s_gis_latlon, s_gis_latlon$group)
#delete group id so that we can have 2-column matrix for Polygon
p_groups1 <- lapply(p_groups, function(x) x[,3] <- NULL; x )
# turn each element of list into a polygon
p_groups1 <- lapply(names(p_groups1),
function(x) b <- Polygon(p_groups1[[x]])
b
)
#turn list of polygons into Polygons
ps <- Polygons(p_groups1,1)
data <- s_gis %>%
group_by(group) %>%
summarize(district_wealthrange = mean(wealthrange))
#create SpatialPolygons object
sps <- SpatialPolygons(ps@Polygons)
I'm getting the error Error in SpatialPolygons(ps@Polygons) :
no slot of name "Polygons" for this object of class "Polygon"
r sp spdep
New contributor
add a comment |
My goal is to find neighbors from my SpatialPolygons object using the poly2nb()
command from the sp
package in R.
This is my code thus far:
p <- s_gis %>%
select(long, lat) %>%
Polygon()
ps <- Polygons(list(p), 1000)
sps <- SpatialPolygons(list(ps))
where s_gis is my dataset. I'm otherwise able to make a successful SpatialPolygons object except for the fact that the slot for plotOrder reads 1, instead of 636353 like it is in my dataset.
Running the poly2nb()
commands returns an error Error in sp$mbxv[i]:(n * 2) : argument of length 0
which I'm assuming is coming from the fact that it's finding 0 neighbors given that I only have a plotOrder of 1.
How do I modify the plotOrder?
In addition, regarding my error message from the poly2nb()
command, if the problem runs deeper, can someone shed some insight as to why?
I have also tried ps@plotOrder <- s_gis$order
to no avail.
EDIT:
#get lat, long, and groupid
s_gis_latlon <- s_gis %>%
select(long,lat, group)
#group lists by group id
p_groups <- split(s_gis_latlon, s_gis_latlon$group)
#delete group id so that we can have 2-column matrix for Polygon
p_groups1 <- lapply(p_groups, function(x) x[,3] <- NULL; x )
# turn each element of list into a polygon
p_groups1 <- lapply(names(p_groups1),
function(x) b <- Polygon(p_groups1[[x]])
b
)
#turn list of polygons into Polygons
ps <- Polygons(p_groups1,1)
data <- s_gis %>%
group_by(group) %>%
summarize(district_wealthrange = mean(wealthrange))
#create SpatialPolygons object
sps <- SpatialPolygons(ps@Polygons)
I'm getting the error Error in SpatialPolygons(ps@Polygons) :
no slot of name "Polygons" for this object of class "Polygon"
r sp spdep
New contributor
What'ss_gis
? Can you show us its summary() and maybe its head()? What doessps
end up as? Is it one polygon or many? How are you runningpoly2nb
to get that error? What are you running it on? Onsps
? Do you care about the plot order or working out the neighbourhood?
– Spacedman
Apr 5 at 23:37
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends upSlot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
I'm runnningpoly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!
– Lathan
Apr 5 at 23:49
add a comment |
My goal is to find neighbors from my SpatialPolygons object using the poly2nb()
command from the sp
package in R.
This is my code thus far:
p <- s_gis %>%
select(long, lat) %>%
Polygon()
ps <- Polygons(list(p), 1000)
sps <- SpatialPolygons(list(ps))
where s_gis is my dataset. I'm otherwise able to make a successful SpatialPolygons object except for the fact that the slot for plotOrder reads 1, instead of 636353 like it is in my dataset.
Running the poly2nb()
commands returns an error Error in sp$mbxv[i]:(n * 2) : argument of length 0
which I'm assuming is coming from the fact that it's finding 0 neighbors given that I only have a plotOrder of 1.
How do I modify the plotOrder?
In addition, regarding my error message from the poly2nb()
command, if the problem runs deeper, can someone shed some insight as to why?
I have also tried ps@plotOrder <- s_gis$order
to no avail.
EDIT:
#get lat, long, and groupid
s_gis_latlon <- s_gis %>%
select(long,lat, group)
#group lists by group id
p_groups <- split(s_gis_latlon, s_gis_latlon$group)
#delete group id so that we can have 2-column matrix for Polygon
p_groups1 <- lapply(p_groups, function(x) x[,3] <- NULL; x )
# turn each element of list into a polygon
p_groups1 <- lapply(names(p_groups1),
function(x) b <- Polygon(p_groups1[[x]])
b
)
#turn list of polygons into Polygons
ps <- Polygons(p_groups1,1)
data <- s_gis %>%
group_by(group) %>%
summarize(district_wealthrange = mean(wealthrange))
#create SpatialPolygons object
sps <- SpatialPolygons(ps@Polygons)
I'm getting the error Error in SpatialPolygons(ps@Polygons) :
no slot of name "Polygons" for this object of class "Polygon"
r sp spdep
New contributor
My goal is to find neighbors from my SpatialPolygons object using the poly2nb()
command from the sp
package in R.
This is my code thus far:
p <- s_gis %>%
select(long, lat) %>%
Polygon()
ps <- Polygons(list(p), 1000)
sps <- SpatialPolygons(list(ps))
where s_gis is my dataset. I'm otherwise able to make a successful SpatialPolygons object except for the fact that the slot for plotOrder reads 1, instead of 636353 like it is in my dataset.
Running the poly2nb()
commands returns an error Error in sp$mbxv[i]:(n * 2) : argument of length 0
which I'm assuming is coming from the fact that it's finding 0 neighbors given that I only have a plotOrder of 1.
How do I modify the plotOrder?
In addition, regarding my error message from the poly2nb()
command, if the problem runs deeper, can someone shed some insight as to why?
I have also tried ps@plotOrder <- s_gis$order
to no avail.
EDIT:
#get lat, long, and groupid
s_gis_latlon <- s_gis %>%
select(long,lat, group)
#group lists by group id
p_groups <- split(s_gis_latlon, s_gis_latlon$group)
#delete group id so that we can have 2-column matrix for Polygon
p_groups1 <- lapply(p_groups, function(x) x[,3] <- NULL; x )
# turn each element of list into a polygon
p_groups1 <- lapply(names(p_groups1),
function(x) b <- Polygon(p_groups1[[x]])
b
)
#turn list of polygons into Polygons
ps <- Polygons(p_groups1,1)
data <- s_gis %>%
group_by(group) %>%
summarize(district_wealthrange = mean(wealthrange))
#create SpatialPolygons object
sps <- SpatialPolygons(ps@Polygons)
I'm getting the error Error in SpatialPolygons(ps@Polygons) :
no slot of name "Polygons" for this object of class "Polygon"
r sp spdep
r sp spdep
New contributor
New contributor
edited Apr 6 at 18:20
Lathan
New contributor
asked Apr 5 at 23:25
LathanLathan
32
32
New contributor
New contributor
What'ss_gis
? Can you show us its summary() and maybe its head()? What doessps
end up as? Is it one polygon or many? How are you runningpoly2nb
to get that error? What are you running it on? Onsps
? Do you care about the plot order or working out the neighbourhood?
– Spacedman
Apr 5 at 23:37
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends upSlot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
I'm runnningpoly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!
– Lathan
Apr 5 at 23:49
add a comment |
What'ss_gis
? Can you show us its summary() and maybe its head()? What doessps
end up as? Is it one polygon or many? How are you runningpoly2nb
to get that error? What are you running it on? Onsps
? Do you care about the plot order or working out the neighbourhood?
– Spacedman
Apr 5 at 23:37
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends upSlot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
I'm runnningpoly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!
– Lathan
Apr 5 at 23:49
What's
s_gis
? Can you show us its summary() and maybe its head()? What does sps
end up as? Is it one polygon or many? How are you running poly2nb
to get that error? What are you running it on? On sps
? Do you care about the plot order or working out the neighbourhood?– Spacedman
Apr 5 at 23:37
What's
s_gis
? Can you show us its summary() and maybe its head()? What does sps
end up as? Is it one polygon or many? How are you running poly2nb
to get that error? What are you running it on? On sps
? Do you care about the plot order or working out the neighbourhood?– Spacedman
Apr 5 at 23:37
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends up
Slot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends up
Slot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
I'm runnning
poly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!– Lathan
Apr 5 at 23:49
I'm runnning
poly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!– Lathan
Apr 5 at 23:49
add a comment |
1 Answer
1
active
oldest
votes
Now we know enough to reproduce your error message, I'll do that with a data frame of lat-long numbers:
> library(sp)
> s_gis = data.frame(long=runif(5), lat=runif(5))
that should be equivalent to your s_gis
with lat-long selected. Continue with your code to make sps
:
> p = Polygon(s_gis)
> ps = Polygons(list(p), 1000)
> sps = SpatialPolygons(list(ps))
and now use the spdep
package:
> library(spdep)
Loading required package: Matrix
> poly2nb(sps, queen=FALSE)
Error in sp$mbxv[i]:(n * 2) : argument of length 0
>
and there's your error.
poly2nb
computes the adjacency matrix between polygons. How many polygons have you got?
> length(sps)
[1] 1
> plot(sps)
One! (although it looks a bit like two but that's because the random lines cross over. This is one ring). No wonder it failed! This data is simply a set of point coordinates in each row - how do you think this data frame could define more than one polygon?
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in mysps
object; however, it's nested within a list which I can't seem to index. Thus,poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.
– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
);
);
Lathan is a new contributor. Be nice, and check out our Code of Conduct.
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%2fgis.stackexchange.com%2fquestions%2f317953%2fthe-slot-for-plotorder-comes-up-as-1-instead-of-a-vector-with-length-specific%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Now we know enough to reproduce your error message, I'll do that with a data frame of lat-long numbers:
> library(sp)
> s_gis = data.frame(long=runif(5), lat=runif(5))
that should be equivalent to your s_gis
with lat-long selected. Continue with your code to make sps
:
> p = Polygon(s_gis)
> ps = Polygons(list(p), 1000)
> sps = SpatialPolygons(list(ps))
and now use the spdep
package:
> library(spdep)
Loading required package: Matrix
> poly2nb(sps, queen=FALSE)
Error in sp$mbxv[i]:(n * 2) : argument of length 0
>
and there's your error.
poly2nb
computes the adjacency matrix between polygons. How many polygons have you got?
> length(sps)
[1] 1
> plot(sps)
One! (although it looks a bit like two but that's because the random lines cross over. This is one ring). No wonder it failed! This data is simply a set of point coordinates in each row - how do you think this data frame could define more than one polygon?
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in mysps
object; however, it's nested within a list which I can't seem to index. Thus,poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.
– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
add a comment |
Now we know enough to reproduce your error message, I'll do that with a data frame of lat-long numbers:
> library(sp)
> s_gis = data.frame(long=runif(5), lat=runif(5))
that should be equivalent to your s_gis
with lat-long selected. Continue with your code to make sps
:
> p = Polygon(s_gis)
> ps = Polygons(list(p), 1000)
> sps = SpatialPolygons(list(ps))
and now use the spdep
package:
> library(spdep)
Loading required package: Matrix
> poly2nb(sps, queen=FALSE)
Error in sp$mbxv[i]:(n * 2) : argument of length 0
>
and there's your error.
poly2nb
computes the adjacency matrix between polygons. How many polygons have you got?
> length(sps)
[1] 1
> plot(sps)
One! (although it looks a bit like two but that's because the random lines cross over. This is one ring). No wonder it failed! This data is simply a set of point coordinates in each row - how do you think this data frame could define more than one polygon?
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in mysps
object; however, it's nested within a list which I can't seem to index. Thus,poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.
– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
add a comment |
Now we know enough to reproduce your error message, I'll do that with a data frame of lat-long numbers:
> library(sp)
> s_gis = data.frame(long=runif(5), lat=runif(5))
that should be equivalent to your s_gis
with lat-long selected. Continue with your code to make sps
:
> p = Polygon(s_gis)
> ps = Polygons(list(p), 1000)
> sps = SpatialPolygons(list(ps))
and now use the spdep
package:
> library(spdep)
Loading required package: Matrix
> poly2nb(sps, queen=FALSE)
Error in sp$mbxv[i]:(n * 2) : argument of length 0
>
and there's your error.
poly2nb
computes the adjacency matrix between polygons. How many polygons have you got?
> length(sps)
[1] 1
> plot(sps)
One! (although it looks a bit like two but that's because the random lines cross over. This is one ring). No wonder it failed! This data is simply a set of point coordinates in each row - how do you think this data frame could define more than one polygon?
Now we know enough to reproduce your error message, I'll do that with a data frame of lat-long numbers:
> library(sp)
> s_gis = data.frame(long=runif(5), lat=runif(5))
that should be equivalent to your s_gis
with lat-long selected. Continue with your code to make sps
:
> p = Polygon(s_gis)
> ps = Polygons(list(p), 1000)
> sps = SpatialPolygons(list(ps))
and now use the spdep
package:
> library(spdep)
Loading required package: Matrix
> poly2nb(sps, queen=FALSE)
Error in sp$mbxv[i]:(n * 2) : argument of length 0
>
and there's your error.
poly2nb
computes the adjacency matrix between polygons. How many polygons have you got?
> length(sps)
[1] 1
> plot(sps)
One! (although it looks a bit like two but that's because the random lines cross over. This is one ring). No wonder it failed! This data is simply a set of point coordinates in each row - how do you think this data frame could define more than one polygon?
answered Apr 6 at 8:18
SpacedmanSpacedman
24.9k23551
24.9k23551
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in mysps
object; however, it's nested within a list which I can't seem to index. Thus,poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.
– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
add a comment |
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in mysps
object; however, it's nested within a list which I can't seem to index. Thus,poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.
– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in my
sps
object; however, it's nested within a list which I can't seem to index. Thus, poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.– Lathan
Apr 6 at 18:24
I've edited my original question. I've tried grouping my coordinates by a group id (which corresponds to each polygon). However, I'm getting a strange lists within a list issue when I make my SpatialPolygon object. The correct plot order is in my
sps
object; however, it's nested within a list which I can't seem to index. Thus, poly2nb()
is still returning the same error message since it's not seeing the plot order and consequently not seeing the correct list of multiple polygon objects that I have.– Lathan
Apr 6 at 18:24
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
You've completely changed the question now. I answered your question about the error you were getting from poly2nb (which didn't even relate to the title about the plot order, but never mind) and now you've added a load of stuff that gives a different error, you've still not shown us some sample data to make a reproducible answer, and I suspect you've left out some important packages necessary to make your code run. I would revert your edits, mark my answer as an answer, and create a new question with your new code, some sample data, and your new error message.
– Spacedman
Apr 7 at 11:03
add a comment |
Lathan is a new contributor. Be nice, and check out our Code of Conduct.
Lathan is a new contributor. Be nice, and check out our Code of Conduct.
Lathan is a new contributor. Be nice, and check out our Code of Conduct.
Lathan is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- 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%2fgis.stackexchange.com%2fquestions%2f317953%2fthe-slot-for-plotorder-comes-up-as-1-instead-of-a-vector-with-length-specific%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
What's
s_gis
? Can you show us its summary() and maybe its head()? What doessps
end up as? Is it one polygon or many? How are you runningpoly2nb
to get that error? What are you running it on? Onsps
? Do you care about the plot order or working out the neighbourhood?– Spacedman
Apr 5 at 23:37
s_gis is one of the datasets I'm using. The summary is quite large; however, I did select out long and lat which results in a tibble with dimensions 661228 x 2. sps ends up
Slot "plotOrder": [1] 1 Slot "labpt": [1] 76.83899 29.49845 Slot "ID": [1] "1000" Slot "area": [1] 196.6975 Slot "coords": # I removed these to save char. space Slot "plotOrder": [1] 1 Slot "bbox": min max x 68.186249 97.41529 y 6.755953 37.07827 Slot "proj4string": CRS arguments: +proj=longlat +datum=WGS84
– Lathan
Apr 5 at 23:46
I'm runnning
poly2nb(sps, queen = FALSE)
and I care more about working out the neighborhood. Thanks so much for your quick response!– Lathan
Apr 5 at 23:49