Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Pls write it in python with comments so that i can understand. Thanks in advanced. undefined Background In this assignment you will be implementing a
Pls write it in python with comments so that i can understand. Thanks in advanced.undefined
Background In this assignment you will be implementing a portion of a Geographic Information System (GIS). A GIS is a computer system used to organize, categorize, and analyze geographical data in order to produce accurate depiction of the real world. The system uses multiple layers of information to achieve this task. The data layers are split into a grid and represented as a matrix with m rows and n columns where each entry in the matrix contains the type of land at that point on the map. An entry Aij is the ith row and jth column in our map matrix. We assume that App is the first element in our matrix. The graphic below will assist in visualizing the process: Transportation (1) Agricultural (A) 0 1 2 3 4 5 6 7 Residential (R) 0 1 2 |--1---- Commercial (C) 3 4 5 6 Water (W) Real World Map (Bird's Eye View) Undeveloped Land (U) Real World Map Figure 1 As seen in the previous example, our GIS utilizes 6 different data layers. We call these layers the map types as they classify regions of different land on our map. Thus, each entry in our map matrix can be one of the 6 map types. Transportation (T) Agricultural (A) Residential (R) Commercial (C) Water (W) Undeveloped land (U) Our GIS will store the map information as a list of lists. If we have a list named map, then map[i][j] will store the map type at row i, column j. Each entry will contain a string that corresponds to 1 of the 6 possible map types listed above. The list representation of the map in Figure 1 is shown below: ['a', [['A','A','A' 'A 'A , ['w', 'w', 'w', 'W ['W', 'w', 'W', 'w 'U', 'U','', 'U'], 'R', 'R'i, 'T','T'] , 'R'], 'U', 'U'], ,'U'], 'T 'R','U','U']] ['T', ['U', '0', U' One usage of the system is to be able to easily identify whether or not a piece of land (entry in the map matrix) is deemed commercially buildable. A piece of land at Aij is deemed commercially buildable if the following conditions hold: The entry at Aij has map type U The entry Ajj is not on the edges of the map (the first and last rows and columns). The entry Aij is not adjacent with an entry of map type R or map type A. Note that adjacent entries are entries to the top, bottom, left, and right of the current cell. Based on the criteria and the map representation of Figure 1, it can be seen that A4,2 is commercially buildable and A1,4 is not commercially buildable. Please read the requirements below to implement the GIS system! determine whether or not a piece of land is commercially buildable. The requirements of the system are given below. Please ensure that your functions have the EXACT naming as specified! Failure to do so will result in lost marks. 1. Define a function countType(map_data, map_type): map_data: A list of lists representing the data for a given map. map_type: A string representing a map type ('T','A', 'R','C', 'W', or 'U') Return: An integer representing the number of times map_type occurs in map_data. 2. Define a function classify Map(map_data): map_data: A list of lists representing the data for a given map. Return: A map classification according to the following rules: The string Suburban if the number of 'R' cells is greater than 50% of all cells. The string Farmland if the number of 'A' cells is greater than 50% of all cells. The string Conservation if the number of 'U' cells plus the number of 'W' cells is greater than 50% of all cells. The string City if the number of 'C' cells is greater than 50% of all cells and the number of 'U' cells plus the number of 'A' cells is between 10% and 20% of all cells (inclusive). The string Mixed if none of the above criteria are met. (Hint, use your countType function coupled with the fact that the total cells in map_data is given by m*n) 3. Define a function isolate Type(map_data, map_type): map_data: A list of lists representing the data for a given map. map_type: A string representing a map type ('T', 'A', 'R', 'C', 'W', or 'U') Return: A new list of lists that represent map_data as a matrix but all entries that are not equal to map_type are replaced with a string containing only a space (""). 4. Define a function commerciallyBuildable(map_data, i, j): map_data: A list of lists representing the data for a given map. i: An integer representing a given row in map_data. j: An integer representing a given row in map_data. Return: True if map_data[i][] is commercially buildable, otherwise False. (Refer to the background section to determine what is deemed commercially buildable Background In this assignment you will be implementing a portion of a Geographic Information System (GIS). A GIS is a computer system used to organize, categorize, and analyze geographical data in order to produce accurate depiction of the real world. The system uses multiple layers of information to achieve this task. The data layers are split into a grid and represented as a matrix with m rows and n columns where each entry in the matrix contains the type of land at that point on the map. An entry Aij is the ith row and jth column in our map matrix. We assume that App is the first element in our matrix. The graphic below will assist in visualizing the process: Transportation (1) Agricultural (A) 0 1 2 3 4 5 6 7 Residential (R) 0 1 2 |--1---- Commercial (C) 3 4 5 6 Water (W) Real World Map (Bird's Eye View) Undeveloped Land (U) Real World Map Figure 1 As seen in the previous example, our GIS utilizes 6 different data layers. We call these layers the map types as they classify regions of different land on our map. Thus, each entry in our map matrix can be one of the 6 map types. Transportation (T) Agricultural (A) Residential (R) Commercial (C) Water (W) Undeveloped land (U) Our GIS will store the map information as a list of lists. If we have a list named map, then map[i][j] will store the map type at row i, column j. Each entry will contain a string that corresponds to 1 of the 6 possible map types listed above. The list representation of the map in Figure 1 is shown below: ['a', [['A','A','A' 'A 'A , ['w', 'w', 'w', 'W ['W', 'w', 'W', 'w 'U', 'U','', 'U'], 'R', 'R'i, 'T','T'] , 'R'], 'U', 'U'], ,'U'], 'T 'R','U','U']] ['T', ['U', '0', U' One usage of the system is to be able to easily identify whether or not a piece of land (entry in the map matrix) is deemed commercially buildable. A piece of land at Aij is deemed commercially buildable if the following conditions hold: The entry at Aij has map type U The entry Ajj is not on the edges of the map (the first and last rows and columns). The entry Aij is not adjacent with an entry of map type R or map type A. Note that adjacent entries are entries to the top, bottom, left, and right of the current cell. Based on the criteria and the map representation of Figure 1, it can be seen that A4,2 is commercially buildable and A1,4 is not commercially buildable. Please read the requirements below to implement the GIS system! determine whether or not a piece of land is commercially buildable. The requirements of the system are given below. Please ensure that your functions have the EXACT naming as specified! Failure to do so will result in lost marks. 1. Define a function countType(map_data, map_type): map_data: A list of lists representing the data for a given map. map_type: A string representing a map type ('T','A', 'R','C', 'W', or 'U') Return: An integer representing the number of times map_type occurs in map_data. 2. Define a function classify Map(map_data): map_data: A list of lists representing the data for a given map. Return: A map classification according to the following rules: The string Suburban if the number of 'R' cells is greater than 50% of all cells. The string Farmland if the number of 'A' cells is greater than 50% of all cells. The string Conservation if the number of 'U' cells plus the number of 'W' cells is greater than 50% of all cells. The string City if the number of 'C' cells is greater than 50% of all cells and the number of 'U' cells plus the number of 'A' cells is between 10% and 20% of all cells (inclusive). The string Mixed if none of the above criteria are met. (Hint, use your countType function coupled with the fact that the total cells in map_data is given by m*n) 3. Define a function isolate Type(map_data, map_type): map_data: A list of lists representing the data for a given map. map_type: A string representing a map type ('T', 'A', 'R', 'C', 'W', or 'U') Return: A new list of lists that represent map_data as a matrix but all entries that are not equal to map_type are replaced with a string containing only a space (""). 4. Define a function commerciallyBuildable(map_data, i, j): map_data: A list of lists representing the data for a given map. i: An integer representing a given row in map_data. j: An integer representing a given row in map_data. Return: True if map_data[i][] is commercially buildable, otherwise False. (Refer to the background section to determine what is deemed commercially buildableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started