Skip to main content

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id:

  • Create a linestring table from polygon
  • Import to postgis
  • Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I dontdon't know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by otheranother field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id:

  • Create a linestring table from polygon
  • Import to postgis
  • Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I dont know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by other field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id:

  • Create a linestring table from polygon
  • Import to postgis
  • Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I don't know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by another field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id: -Create a linestring table from polygon -Import to postgis -Get the length of each line

  • Create a linestring table from polygon
  • Import to postgis
  • Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description hereenter image description here

For this, I have a select, but I dont know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by other field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id: -Create a linestring table from polygon -Import to postgis -Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I dont know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by other field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id:

  • Create a linestring table from polygon
  • Import to postgis
  • Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I dont know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by other field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks

Source Link
Pablo Pardo
  • 1.1k
  • 11
  • 20

Remove inner polygons postgis

I'm trying to remove inner polygons with postgis. I've created a routine, that resumes in:

From a polygon table, with a unique id: -Create a linestring table from polygon -Import to postgis -Get the length of each line

Now I have a table with, for example, 5 linestrings for each id, each linestring was a polygon, and I want to get ONLY the longest line from each ID.

enter image description here

For this, I have a select, but I dont know how to group the geometry, to get ONLY the longest line

select  id, geom as length from esp_lines group by id

I have to group it by other field, but I don't know which one.

The other solution I've found is:

select  id, max(geom) as length from esp_lines group by id

but max(geom) doesn't give me the expected result (the longest linestring)

Does anybody know if is there any function to get the longest linestring of a group?

Thanks