AnswerBun.com

Point pattern analysis in R

I am quite new to R and am having some trouble setting up my data for some point pattern analysis.

What I want to do: conduct a point pattern analysis on NYC arrest data and see if there exists a spatial dependence between arrests and Covid-19 cases.

What I’ve done so far: downloaded data in the form of shapefiles

https://data.cityofnewyork.us/City-Government/Borough-Boundaries/tqmj-j8zm (the ZIP code boundaries)

https://www1.nyc.gov/site/nypd/stats/crime-statistics/citywide-crime-stats.page (year to date data for arrests in NYC by zip code)

Code:

library(readxl)
library(rgdal) #Brings Spatial Data in R
library(spatstat) # Spatial Statistics
library(lattice) #Graphing
library(maptools)
library(raster)
library(ggplot2)
library(RColorBrewer)
library(broom)

# Load nyc zip code boundary polygon shapefile 
s <- readOGR("/Users/my_name/Documents/project/zip","zip")
nyc <- as(s,"owin")

### OGR data source with driver: ESRI Shapefile 
Source: "/Users/my_name/Documents/project/zip", layer: "zip"
with 263 features

# Load nyc arrests point feature shapefile
> s <- readOGR("/Users/my_name/Documents/project/nycarrests/","geo1")

### OGR data source with driver: ESRI Shapefile 
Source: "/Users/my_name/Documents/project/nycarrests", layer: "geo1"
with 103376 features
It has 19 fields

#Converting the dataset into a point pattern
arrests <- as(s,"ppp”) 

### Error in as.ppp.SpatialPointsDataFrame(from) : 
  Only projected coordinates may be converted to spatstat class objects

This gave me the error above.

I know the error has to do with the coordinates not being in the Cartesian coordinates.

How can I convert my sp object to have (projected) Cartesian coordinates in order to convert it to a point pattern (Poisson point process) ?

Geographic Information Systems Asked on December 28, 2020

0 Answers

Add your own answers!

Related Questions

Get altitude value from WMS

1  Asked on December 18, 2020

       

create a maximum raster using gdal_calc

2  Asked on December 17, 2020 by user83420

     

Extracting data from a raster

3  Asked on December 17, 2020 by ktop

         

Stop Leaflet event propagation?

2  Asked on December 17, 2020 by muhammad

 

Customize color pallets widget

0  Asked on December 17, 2020 by geofausto

         

Not able to dispaly large shapefiles

0  Asked on December 17, 2020 by heljor

   

How to convert grid to vector in SAGA?

1  Asked on December 17, 2020 by barbora-basslerov

       

Export to CAD error

0  Asked on December 17, 2020 by ahmet-kasap

   

Overriding Geonode templatetag file

1  Asked on December 17, 2020 by falcoa

   

Create ESRI shapefile with attributes from mySQL

4  Asked on December 17, 2020 by jsz

     

JSON Error? – Unfolding library – Bug or something else?

2  Asked on December 17, 2020 by geosphere

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.