0

I have the following dataset in R - this dataset contains a list of geocoded addresses (Canada) with their Postal Codes, Longitudes and Latitudes: https://www.dropbox.com/scl/fi/9kjoqsppb85ip0tdc5wmr/stackoverflow_example.csv?rlkey=cwjk222jnoz8c9cgbt01p6bep&dl=0

I loaded this data into R:

library(httr)
library(data.table)

url <- "https://www.dropbox.com/scl/fi/9kjoqsppb85ip0tdc5wmr/stackoverflow_example.csv?rlkey=cwjk222jnoz8c9cgbt01p6bep&dl=1"

response <- GET(url)

df <- fread(content(response, "text"), sep = ",", quote = "", fill = TRUE)


> head(df)
         "" "latitude" "longitude" "source_id"                   "id" "group_id" "street_no"            "street"       "str_name" "str_type" "str_dir" "unit"     "city" "postal_code"
1: "999976"   44.25845   -76.46308          "" "6baaa1692aaaa7b496aa"    2494328       "104" "POINT ST. MARK DR" "POINT ST. MARK"       "DR"        ""     "" "KINGSTON"     "K7K 6X8"
2: "999977"   44.26391   -76.45090          "" "1f01e7839e59727d95a3"    2508891       "229"      "GREENLEES DR"      "GREENLEES"       "DR"        ""     "" "KINGSTON"     "K7K 6R1"
3: "999978"   44.26262   -76.45164          "" "289d509f161955a7b5ad"    2519600       "443"        "MAUREEN ST"        "MAUREEN"       "ST"        ""     "" "KINGSTON"     "K7K 7M2"
4: "999979"   44.26545   -76.45230          "" "e6516f9c0e173b684627"    2506548       "198"      "GREENLEES DR"      "GREENLEES"       "DR"        ""     "" "KINGSTON"     "K7K 6P7"
5: "999983"   44.23525   -76.49264          "" "2576c9ff82b86638737c"    2508273        "22"         "ELLICE ST"         "ELLICE"       "ST"        ""     "" "KINGSTON"     "K7K 1M5"
6: "999993"   44.26520   -76.45182          "" "03aaecc65f29e1e04fe1"    2507798       "212"      "GREENLEES DR"      "GREENLEES"       "DR"        ""     "" "KINGSTON"     "K7K 6P7"
               "full_addr" "city_pcs" "str_name_pcs" "str_type_pcs" "str_dir_pcs" "csduid"  "csdname" "pruid"         "provider"
1: "104 POINT ST. MARK DR" "KINGSTON"   "PT ST MARK"           "DR"            ""  3510010 "Kingston"      35 "City of Kingston"
2:      "229 GREENLEES DR" "KINGSTON"    "GREENLEES"           "DR"            ""  3510010 "Kingston"      35 "City of Kingston"
3:        "443 MAUREEN ST" "KINGSTON"      "MAUREEN"           "ST"            ""  3510010 "Kingston"      35 "City of Kingston"
4:      "198 GREENLEES DR" "KINGSTON"    "GREENLEES"           "DR"            ""  3510010 "Kingston"      35 "City of Kingston"
5:          "22 ELLICE ST" "KINGSTON"       "ELLICE"           "ST"            ""  3510010 "Kingston"      35 "City of Kingston"
6:      "212 GREENLEES DR" "KINGSTON"    "GREENLEES"           "DR"            ""  3510010 "Kingston"      35 "City of Kingston"

My Question: Using this data, I am trying to "approximate" the geographical boundary of each Postal Code and visualize the result.

In the past, it was suggested to me that a technique called "Polygon Clipping" might be useful for accomplishing this task.

I am trying to learn how "Polygon Clipping" might be useful in accomplishing this task - but I am not sure how to get started with this. In the end, I would like to have something like a shapefile that contains the "perimeter" (in longitude and latitude coordinates) of each Postal Code.

How can I do this?

Note:

1 Answer 1

3

"Polygon clipping" in GIS means to take one polygon, A, and a clipping polygon, B, and compute the bits of A that are inside B. For example you might have a polygon of forest, and a polygon of a state boundary, and clipping the forest to the state boundary gives you the forest inside the state.

I don't see how this helps you define polygon regions for your postcode centres, but it answers the question in the title.

2
  • thank you so much for your answer! I have been trying to research and learn different ways to approximate this postal code problem - do you think if you have time, you can please show me how I can get started with the sample that I have posted? thank you so much!
    – stats_noob
    Commented Aug 26, 2023 at 15:42
  • 3
    Can you write a post where the title is more relevant to the question? Anyone seeing this in a list of question titles on here doesn't want to see an answer about making coverage polygons from a point data set...
    – Spacedman
    Commented Aug 26, 2023 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.