Jump to content

 
Photo

ProportionOverlap() - MapBasic

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Gürkan Alkan

Gürkan Alkan

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

Hi everyone. I want to ask you a question. I try to find the ratio of intersection between the cities and polygon(is drawn by the user). I see that ProportionOverlap( ) function directly computes it.
Unfortunately I cannot solve the solution.
This is my sub procedure:
[iller:table name]

sub poligonum
dim nesnem as object
nesnem=CommandInfo(CMD_INFO_CUSTOM_OBJ)
insert into WindowInfo(frontwindow(),WIN_INFO_TABLE)(OBJ) values(nesnem)
select il_adi,proportionoverlap(iller.obj,nesnem) from iller where iller.obj intersects nesnem into selection
browse * from selection
end sub


This subprocedure finds the cities' names(in my procedure: il_adi). But it cannot compute the proportionoverlap. Is there anyone know the solution..?

#2
gregsd

gregsd

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 169 posts
  • Gender:Male
  • Location:Surrey, England.
  • Interests:Cycling, mostly off-road (MTB) riding.
  • United Kingdom

Hi everyone. I want to ask you a question. I try to find the ratio of intersection between the cities and polygon(is drawn by the user). I see that ProportionOverlap( ) function directly computes it.
Unfortunately I cannot solve the solution.
This is my sub procedure:
[iller:table name]

sub poligonum
dim nesnem as object
nesnem=CommandInfo(CMD_INFO_CUSTOM_OBJ)
insert into WindowInfo(frontwindow(),WIN_INFO_TABLE)(OBJ) values(nesnem)
select il_adi,proportionoverlap(iller.obj,nesnem) from iller where iller.obj intersects nesnem into selection
browse * from selection
end sub


This subprocedure finds the cities' names(in my procedure: il_adi). But it cannot compute the proportionoverlap. Is there anyone know the solution..?


Hi,

A couple of question:

1 - Are the objects in the iller table polygons or points? If they are points then proportionoverlap() won't work.

2 - have you set the coordinate system within your MapBasic application? If not,then MapBasic will default to Lat/Long, which might affect the custom object (nesnem), so the SQL select might not work.

Apart from that, your code should work. Let me know if these couple of suggestions don't work.

Greg.


Greg Driver

GIS Analyst
MapInfo User...!

#3
Gürkan Alkan

Gürkan Alkan

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

Hi,

A couple of question:

1 - Are the objects in the iller table polygons or points? If they are points then proportionoverlap() won't work.

2 - have you set the coordinate system within your MapBasic application? If not,then MapBasic will default to Lat/Long, which might affect the custom object (nesnem), so the SQL select might not work.

Apart from that, your code should work. Let me know if these couple of suggestions don't work.

Greg.

Thank you for your response, Greg.

1-They arenot point.
2-When I set it(in poligonum subprocedure), the result didnot change.

#4
gregsd

gregsd

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 169 posts
  • Gender:Male
  • Location:Surrey, England.
  • Interests:Cycling, mostly off-road (MTB) riding.
  • United Kingdom

Hi,

A couple of question:

1 - Are the objects in the iller table polygons or points? If they are points then proportionoverlap() won't work.

2 - have you set the coordinate system within your MapBasic application? If not,then MapBasic will default to Lat/Long, which might affect the custom object (nesnem), so the SQL select might not work.

Apart from that, your code should work. Let me know if these couple of suggestions don't work.

Greg.

Thank you for your response, Greg.

1-They arenot point.
2-When I set it(in poligonum subprocedure), the result didnot change.


Can you provide a screen-shot of the results returned by your SQL select?


Greg Driver

GIS Analyst
MapInfo User...!

#5
gregsd

gregsd

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 169 posts
  • Gender:Male
  • Location:Surrey, England.
  • Interests:Cycling, mostly off-road (MTB) riding.
  • United Kingdom

Hi,

A couple of question:

1 - Are the objects in the iller table polygons or points? If they are points then proportionoverlap() won't work.

2 - have you set the coordinate system within your MapBasic application? If not,then MapBasic will default to Lat/Long, which might affect the custom object (nesnem), so the SQL select might not work.

Apart from that, your code should work. Let me know if these couple of suggestions don't work.

Greg.

Thank you for your response, Greg.

1-They arenot point.
2-When I set it(in poligonum subprocedure), the result didnot change.


Can you provide a screen-shot of the results returned by your SQL select?


Forget that last post! :D

This will work:

sub poligonum
dim nesnem as object
dim strcmd as string

nesnem=CommandInfo(CMD_INFO_CUSTOM_OBJ)
insert into WindowInfo(frontwindow(),WIN_INFO_TABLE)(OBJ) values(nesnem)

strcmd = "select il_adi,proportionoverlap(iller.obj,nesnem) from iller where iller.obj intersects nesnem into selection"
run command strcmd

browse * from selection

End Sub

I think the reason that it wasn’t working is that the SQL select statement has been compiled and at this point the object variable (nesnem) is empty, hence no results were returned when the SQL select is executed. To get around this you can use the Run Command to issue a statement, which is interpreted at run-time and picks-up the object created by the user in the object variable (nesnem).

Hope that makes sense?!

Greg.


Greg Driver

GIS Analyst
MapInfo User...!

#6
Gürkan Alkan

Gürkan Alkan

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

Finally it runs. :)
Thank you Greg,




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->